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