my $SUCCESS = 0; my %Error = ( q[No such file or directory] => 1 ); my @out = qx { command here 2>&1 }; my $rc = $?; if ( $rc == $SUCCESS ) { # As I wrote earlier, if command was sucessful, then why would # there be no-file-found error (under normal conditions)? Else, # exit code cannot be trusted. ... = grep { $Error{$_} } @out; ... } ...