in reply to Java to perl
Passing of an array from Java into a Perl is generally done in the form of a scalar reference. There are many other ways but I would prefer scalar reference. Also you need to use the GetIntArrayElements -- which is a jni function which is used to convert the scalar into an array of integers.
For example:
public class arrayforPerl { perl void max( int[] data ) {{ # Get the array elements # my @arrPerl = GetIntArrayElements( $data ); my @arrMax = sort {$a <=> $b} @arrPerl; print "Max: $arrMax[$#arrMax]\n"; }} ## double braces are for the perl code void maxProg() { int[] data = {101, 99, 42, 666, 23}; max( data ); } public static void main(String[] argv) { arrayforPerl javaPerl = new arrayforPerl(); javaPerl.maxProg(); } }
I hope you can build on this
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
| A reply falls below the community's threshold of quality. You may see it by logging in. |