I have a perl script that calls an other perl script by using system()
it's like:
my $returnval= system("perl", $path,$val1, $val2,@myarray);
Because system() returns only the exit status but I want the script's output I want to use backticks.
I tried something like that:
my $returnval = `$path`;
how can I add the parameters the script should receive?
how should the other perl script's return code looks like? At the moment it's like
exit ($myreturnedvalue);
(how) Is it possible to return multiple values?
To go through the shell in order to move data from one perl script to another is not the best solution. You should know that backticks or
qx()
captures whatever is printed to STDOUT. Usingexit ($var)
from the other script is unlikely to be captured properly. You would needprint $var
. But don't do that.Instead, make the other script into a module and use the subroutine directly. This is a simplistic example:
In bar.pm:
In main.pl:
There is a lot more to learn, and I suggest you read up on the documentation.