http://www.perlmonks.org?node_id=1138204


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';