Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: WIFEXITED when system returns none zero

by pme (Prior)
on Aug 11, 2015 at 17:26 UTC ( #1138204=note: print w/replies, xml ) Need Help??


in reply to WIFEXITED when system returns none zero

Hi Neil,

In according to system: "The return value is the exit status of the program as returned by the wait call. To get the actual exit value, shift right by eight."

#!/usr/bin/perl use strict; use warnings; use POSIX qw/ WIFEXITED /; WIFEXITED( (system '/bin/true') >> 8 ) or die "true $!"; WIFEXITED( (system '/bin/false') >> 8 ) or die "false: $!";
UPDATE: You may find autodie interesting.
#!/usr/bin/perl use strict; use warnings; use autodie qw/:all/; system '/bin/true'; system '/bin/false';

Replies are listed 'Best First'.
Re^2: WIFEXITED when system returns none zero
by neilwatson (Priest) on Aug 11, 2015 at 17:34 UTC

    Actually the use of Test:: was intentional. It's part of a test plan. So 'ok' and not 'die'. Good catch on the shift by 8 though.

    Neil Watson
    watson-wilson.ca

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1138204]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (12)
As of 2018-07-20 14:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?















    Results (434 votes). Check out past polls.

    Notices?