use warnings; use strict; BEGIN { open(STDERR, ">stderr2.log") or die "Failed to open log file"; } print STDERR "Oops!\n"; system ('nosuchprogram'); close STDERR; #### Oops! 'nosuchprogram' is not recognized as an internal or external command, operable program or batch file.