Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Handling weird return values with or die

by jeroenes (Priest)
on Jul 05, 2001 at 16:31 UTC ( #94073=note: print w/replies, xml ) Need Help??


in reply to Handling weird return values with or die

But with system that is different. See the doc. Check for a number of -1 to die on start failure:
system("blah foo beer!") <> -1 or die "error: $?";

To die on the exit call, maybe you'd better use some elaborate sceme:

system( @args ) == 0 or syscall_error( $?, "system @args" ); sub syscall_error( my $error = shift; my $name = shift; die "$name failed: $!" if $error == -1; die "$name returned error: ", $error >> 8, ", signal: ", $error & 127, " and dumped_core: ", $error & 128; }
The last sub pulled from the literal info in system.

Hope this helps,

Jeroen
"We are not alone"(FZ)
Updated