How to pass array from java to perl using inline java

S

songtao32

Hi,

I try to pass a float[ ] [ ] array from inline java to perl. I
assign the java array to a perl list variable but it doesn't work. Any
suggestions?

Thanks for help!

Regards,

Tom
 
U

usenet

[a multiposted question]

Please don't multipost. It is considered bad usenet ettiquette.
 
D

DJ Stunks

Hi,

I try to pass a float[ ] [ ] array from inline java to perl. I
assign the java array to a perl list variable but it doesn't work. Any
suggestions?

please post a short, but complete script which demonstrates the
issue. have you read the posting guidelines for this group?

-jp
 
S

songtao32

Hi,

Sorry for the multipost. I apologize.

Here is the script that I try to run:

*****************************************************
use Inline Java => <<'EOJ';
public class TestJavaClass
{

public float[ ] [ ] returnArrayData(){
 
A

Andy

According to the output you've posted, you've succeeded. Perl is
reporting you have an array of pointers to other arrays of numbers.
The question now is how to read the contents of the arrays that were
returned from java.

All languages do not store their numbers in the same way, so the way a
floating point number is stored in Java may not be compatible with the
way Perl stores it. The IEEE defines a standard format for
representing floating point numbers in memory.

If both Perl and Java are IEEE compliant for floating point numbers,
you should have little translation problems between the two languages
(in that if you experiment with the different ways of using arrays in
Perl, one of them should automatically work with what Java returned).
Sorry, I don't know if Perl is IEEE compliant, although I know Java
is.
 
D

DJ Stunks

Hi,

Sorry for the multipost. I apologize.

Here is the script that I try to run:

*****************************************************
use Inline Java => <<'EOJ';
public class TestJavaClass
{

public float[ ] [ ] returnArrayData(){
.
.
.
return ArrayData[m][n];
}

}

EOJ

my @mylist = TestJavaClass. returnArrayData();

print "$mylist[0]";

*****************************************************

I got the following output:

Inline::Java::Array=ARRAY(0xa52e234)

When you respond on this list you're asked to quote the attribution
and some appropriate context. Also this script does not look
"complete".

Anyway, you've said your problem is accessing a 2D array, so why are
you only printing the first dimension? In fact, when you do, Perl is
telling you that that first dimension is itself made up of an array.
This is as it should be.

If you're passing a 2D array, you need to access it in two dimensions.

print $mylist[0][0];

for instance should work, but I'm unable to verify it.

-jp

PS: read perldoc -q vars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top