system("foo") == 0 or die "foo failed; rc=$?"; defined(my $pid = open FOO, "command|") or die "exec failed; $!"; # ... do something with FOO ... close FOO; ($? == 0) or die "sub-process `command' failed; rc=$?";