open LOG ">>std.log" or die $!; im_missing_something_here(); other_calls(); close LOG; sub im_missing_something_here { open STDERR, ">>err.log" or die $!; # Perl can run the shell # if (open(PIPE, "$cmd <$tempfile |")) { # but there is a message in STDERR # if (-s './err.log') { print LOG "ERROR:see err.log, exiting..\n"; close STDERR; die "Killed.\n"; #to default STDERR is intent } ... }