Hi expert
I want to pass one array from one perl script to another perl script.
I don't have problems passing variables. My problem is with the array.
What I am doing:
In the ScriptName 1 :
I am processing some things, but at the end I need to invoke the scriptname 2 and pass some values...
system(scriptname2.pl @array $var1 $var2 $var3 $var4 $var5);
In the ScriptName 2 :
Getting the values from the ScriptName 1
@array = $ARGV[0];
$var1 =$ARGV[1];
$var2 =$ARGV[2];
$var3 = $ARGV[3];
$$var4 =$ARGV[4];
$var5 =$ARGV[5];
Error Found:
Scalar found where operator expected
-------------------------------------------------------
Somebody can help me with that! I was checking references, but to be honest I don't know how to apply it to that particular case...It applies easily parsing arrays to another function, like the nex example:
@array1 = qw/1 2 3/;
@array2 = qw/4 5 6/;
puke( \@array1, \@array2 ); #outputs 123,456
sub puke {
my ($array_ref1, $array_ref2) = @_;
print "$_" foreach @{$array_ref1};
print ",";
print "$_" foreach @{$array_ref2};
}
Thanks!
I want to pass one array from one perl script to another perl script.
I don't have problems passing variables. My problem is with the array.
What I am doing:
In the ScriptName 1 :
I am processing some things, but at the end I need to invoke the scriptname 2 and pass some values...
system(scriptname2.pl @array $var1 $var2 $var3 $var4 $var5);
In the ScriptName 2 :
Getting the values from the ScriptName 1
@array = $ARGV[0];
$var1 =$ARGV[1];
$var2 =$ARGV[2];
$var3 = $ARGV[3];
$$var4 =$ARGV[4];
$var5 =$ARGV[5];
Error Found:
Scalar found where operator expected
-------------------------------------------------------
Somebody can help me with that! I was checking references, but to be honest I don't know how to apply it to that particular case...It applies easily parsing arrays to another function, like the nex example:
@array1 = qw/1 2 3/;
@array2 = qw/4 5 6/;
puke( \@array1, \@array2 ); #outputs 123,456
sub puke {
my ($array_ref1, $array_ref2) = @_;
print "$_" foreach @{$array_ref1};
print ",";
print "$_" foreach @{$array_ref2};
}
Thanks!