How to pass array from java to perl using inline java

Discussion in 'Perl Misc' started by songtao32@gmail.com, Jan 31, 2007.

  1. Guest

    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
    , Jan 31, 2007
    #1
    1. Advertising

  2. Guest

    On Jan 31, 9:27 am, "" <> wrote:
    [a multiposted question]

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


    --
    The best way to get a good answer is to ask a good question.
    David Filmer (http://DavidFilmer.com)
    , Jan 31, 2007
    #2
    1. Advertising

  3. DJ Stunks Guest

    On Jan 31, 10:27 am, "" <>
    wrote:
    > 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
    DJ Stunks, Jan 31, 2007
    #3
  4. Guest

    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(){
    , Jan 31, 2007
    #4
  5. Andy Guest

    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.

    >
    > Inline::Java::Array=ARRAY(0xa52e234)
    >
    Andy, Jan 31, 2007
    #5
  6. DJ Stunks Guest

    On Jan 31, 11:50 am, "" <>
    wrote:
    > 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
    DJ Stunks, Jan 31, 2007
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Abhi
    Replies:
    2
    Views:
    725
    E. Robert Tisdale
    Jul 3, 2003
  2. Alvin
    Replies:
    7
    Views:
    464
    E. Robert Tisdale
    May 6, 2005
  3. Replies:
    3
    Views:
    447
  4. Daniel Vallstrom
    Replies:
    2
    Views:
    1,830
    Kevin Bracey
    Nov 21, 2003
  5. Nish
    Replies:
    4
    Views:
    479
    Thomas Stegen
    Oct 8, 2004
Loading...

Share This Page