If (($fileage <= $modtime) && (-d $_)) { # at this point we know $_ *must* be a directory if ($fileage <= $modtime) && (-f $_)) { # this -f test won't work because you are # testing $_ again and you've just # established that $_ is a directory