if (-d $pathname) { # $pathname exists and is a directory # ... } elsif (-e _) { # $pathname exists, but is NOT a directory # ... } else { # $pathname doesn't even exist # ... }