system('some_shell_command') >> 8 and die "Failed!"; # or else (same thing), system('some_program'); if ($? >> 8 != 0) { die "Failed!"; } #### system('foobar') == 0 or die "Failed!"; # or equivalently system('foobar'); if ($? != 0) { die "Failed!"; } #### if ($? == -1) { print "failed to execute: $!\n"; } elsif ($? & 127) { printf "child died with signal %d, %s coredump\n", ($? & 127), ($? & 128) ? 'with' : 'without'; } else { printf "child exited with value %d\n", $? >> 8; }