I'd like to transfer a matrix from one perl file to another by using a command line with backticks.
On the first file perl, source.pl :
use warnings;
use strict;
my @matrix = (
[1, 2, 3],
[4, 5, 6],
[7, 8, 9]
);
my $results = `perl other_file.pl @matrix`; #option 1
# my $results = `perl other_file.pl '@matrix'`; #option 2
print $results;
On other_file.pl
use strict
use warnings
my @matrix_other = $ARGV[0];
print "mat_adress = ".$matrix_other[1][2]."\n";
After launch source.pl, the terminal output:
- with option 1 : sh: 1: Syntax error: "(" unexpected
- with option 2 : Can't use string ("ARRAY(0x6c0cb8) ARRAY(0x6df410) "...) as an ARRAY ref while "strict refs" in use at other_file.pl line 5.
I've also try to use Symbolic references without success in other_file.pl (output was : "Not an ARRAY reference at other_file.pl")
Any idea ? Thanks a lot.
PS: No problem with a simple variable $var in the command line;