use strict; use warnings; use IPC::Open3; use IO::Select; use POSIX ":sys_wait_h"; use Symbol; my $ERROR=gensym(); my $command="not_a_command"; my ($WRITE, $READ); my $pid; $! = undef; eval {$pid = open3($WRITE, $READ, $ERROR, "$command");}; print "pid is $pid\n" if $pid; if ($@) { print "Trapped error $@"; } elsif (length $!) { print "Detected error: $!"; } else { print "No error"; } #### pid is 3412 Detected error: No such file or directory