http://qs1969.pair.com?node_id=692684

palette has asked for the wisdom of the Perl Monks concerning the following question:

Hi,
I have a .pl script. Inside the .pl script I am using a system command to call another script.

Consider the first script as 1.pl and the second one as 2.pl

There are print stmts in 2.pl and there are chances that 2.pl can throw error.

I have to catch the error in eval block and print the error in the script 1.pl

1.pl code snippet

... .. eval { system("perl 2.pl"); }; if($@) { print "the error that was thrown in 2.pl"; } ...


Pls note if 2.pl is displaying any output that should not be treated as error and caught in $@;