use strict; use warnings; my @dirs = qw ( /root /home /sbin /tmp /lost+found /not-a-dir /etc/passwd ); for (@dirs) { if (! -e ) { print "$_ => does not exist"; next; } if (! -d ) { print "$_ => not a directory"; next; } (opendir(my $FH, $_)) ? print "$_ => ok" : print "$_ => denied"; } __END__ $ perl -l 621211.pl /root => denied /home => ok /sbin => ok /tmp => ok /lost+found => denied /not-a-dir => does not exist /etc/passwd => not a directory