# step1.pl print "This is step1.\n"; exit 0; # step2.pl print "This is step2.\n"; exit 0; # step3.pl print "This is step3.\n"; exit 42; # step4.pl print "This is step4.\n"; exit 0; #### # runner.pl use strict; use warnings; $| = 1; my @scripts = ('step1.pl', 'step2.pl', 'step3.pl', 'step4.pl'); for my $scr (@scripts) { my $cmd = "$^X $scr"; print "Run '$cmd'..."; my $out = qx{$cmd}; my $rc = $? >> 8; print "rc=$rc\n"; print "Output:$out\n"; if ($rc != 0) { print "Main script $0 exit $rc\n"; exit $rc; } } print "All commands finished successfully.\n";