my @bannedF = ('c:/win32app/toolkit', 'c:/winnt', 'C:/WINNT/system32', 'd:/perl', 'd:/brossad'); my $folder = 'c:/TEMP/sdfs'; for (0..$#bannedF) { return BANNED if ($folder eq $bannedF[$_]); # if folder is directly equal to a banned folder if ($mode == INC_SUBDIRS) # if a parent folder is banned then so are the subfolders unless otherwise stated { $folder =~ /^($bannedF[$_]).*/; print "$_ out of $#bannedF - $bannedF[$_] - regexp value : $1\n"; return BANNED if ($1); # example : $folder = c:\temp\one; $bannedF[$_] = c:\temp } }