Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Error trapping from system

by ChemBoy (Priest)
on Sep 20, 2002 at 22:37 UTC ( #199653=note: print w/replies, xml ) Need Help??


in reply to Re: Re: Re: vanishing system call
in thread vanishing system call

Nice catch on the return value of system--but in error cases, it doesn't set $!, but rather $?. Unfortunately, $? doesn't stringify nearly as nicely as $!, but you can get reasonable information (as outlined in perlvar) with a little extra work:

unless (0 == system $cmd) { warn sprintf "External command '%s' failed with exit status %d (sig +nal %d). A core dump %s\n", $cmd, $? >> 8, $? & 127, $? & 128 ? "occurred" : "did not occur"; }



If God had meant us to fly, he would *never* have given us the railroads.
    --Michael Flanders

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://199653]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (10)
As of 2019-09-18 17:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The room is dark, and your next move is ...












    Results (235 votes). Check out past polls.

    Notices?