my $rv = system(...); if ($rv == -1) { die("Unable to launch child: $!\n"); } if ($rv & 127) { die(sprintf("Error executing child: Child died with signal %d, %s coredump\n", ($rv & 127), ($rv & 128) ? 'with' : 'without', )); } if ($rv >> 8) { die(sprintf("Error executing child: Child exited with value %d\n", ($rv >> 8) )); } print("Child ran successfully\n");