I have 2 scripts, say main_script.pl and secondary_script.pl
First I am running the main_script.pl
which calls seconday_script.pl
.
Code looks below for main_script.pl:
#!/usr/bin/perl
use strict;
use warnings;
my $var1 = "val_1";
my $var2 = "val_2";
my $sec_script = "/home/shared/Vinod/Perl_Test/secondary_script.pl";
my $result = `perl $sec_script $var1 $var2`;
print "Result:$result\n";
secondary_script.pl
#!/usr/bin/perl
use strict;
use warnings;
my $arg1 = $ARGV[0];
my $arg2 = $ARGV[1];
....
....
# DO SOME OPEARTION BY USING THE ARGUMENTS PASSED FROM main_script.pl
# FINALLY CREATE AN ARRAY @data
print Dumper(\@data);
Here I can able to generate output in array @data
. But how can I pass this @data
values to main_script.pl
so that it will get stored in result
.
Since in main_script.pl
I have declared result as an scalar
variable. My data value from secondary_script.pl
would be array
, so should I make result as an array variable
? and how can I capture the data in main_script.pl
?