in reply to Script wrapper script

It's impossible to do exactly what you describe. The exit status of a program isn't returned until it exits, at which point there would have to be another program waiting around to report what happened.

I'd be surprised if creating 2 processes for each task is really a problem. The "wrapper" program would just start another script then go to sleep, at which point it would use an extremely small amount of system resources. I frequently start up chains of programs from cron, and have never had problems with this.

But, you can get close to what you want by using do, as chibiryuu suggests, and overriding exit:

my $prog = shift; eval { sub exit { die "exit $_[0]\n"; } do '$prog' or die "Couldn't run '$prog': $!\n"; }; print "'$prog' results: $@\n"; my $childexit; if (!$@) { $childexit = 0; } elsif ($@ =~ /^exit (\d+)$/) { $childexit = $1; } else { $childexit = 1; } CORE::exit($childexit);