if ($strPath eq "/home/dev/jhon" && -d $strPath && -r _) { foreach my $subdir ( qw(work school vacation) ) { if (-d "$StrPath/$subdir/WORKAREA/work && -r _) { my @SubList=<"$StrPath/$subdir/WORKAREA/work/*>; } } } else { #Continue about your business }