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; } #### Bit# 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00 | | | | | | | | | | | | | | | | X7 X6 X5 X4 X3 X2 X1 X0 CD S6 S5 S4 S3 S2 S1 S0 | | | +-- exit code (8bit) | +-- signal code (7bit) | +-- core-dumped flag #### my $exit_status = int( $? / 256 ); # quick and dirty exit-state # decimal arithmetic so to speak # (works for positive numbers)