in reply to wrap 'system LIST' in a (somewhat) more friendly style
BEGIN { *CORE::GLOBAL::system = sub { if ( 0 == CORE::system { $_[0] } @_ ) { return 1 } if ( -1 == $? ) { $@ = "Unable to launch $_[0]: $!" } else { $@ = "$_[0] exited with status " . ($? >> 8); if (my $sig = $? & 127) { $@ .= " after receiving signal $sig" + } if ($? & 128) {$@ .= " (core dumped)" } } return; }; } system(qw(perl -u -e 1)) or die "$@\n";
Now I wouldn't recommend you'd actually do this, as it will wreak havoc on all modules that expect system() to work the "old" way. But when we get fully controllable lexical pragma's (5.9.1?), then you would be able to do this in your own code without interfering with any other modules (by checking the appropriate pragma in this sub and reverting to the old behaviour if the pragma would not be set).
Liz
|
|---|