$ perl -MErrno=ENOENT -le' $found = -e shift; die("stat: $!\n") if !defined($found) && $! != ENOENT; print($found ? "found" : "not found"); ' foo/bar not found $ touch foo/bar $ perl -MErrno=ENOENT -le' $found = -e shift; die("stat: $!\n") if !defined($found) && $! != ENOENT; print($found ? "found" : "not found"); ' foo/bar found $ chmod a-x foo $ perl -MErrno=ENOENT -le' $found = -e shift; die("stat: $!\n") if !defined($found) && $! != ENOENT; print($found ? "found" : "not found"); ' foo/bar stat: Permission denied