use strict; use IPC::Open2; use Carp; eval { open2(*RDRFH, *WTRFH, 'xxx'); }; if ($@) { if ($@ =~ /^open2/) { warn "open2 failed: $!\n$@\n"; return; } die; # reraise unforeseen exception } warn "HELLO BUDDY"; __END__ 'xxx' is not recognized as an internal or external command, operable program or batch file. HELLO BUDDY at - line 13.