# nifty trick -- make a hash to ease the lookup in the findit sub my %excludeit; # now set the keys of the hash # (== the members of your excluded directories array) # to have values of 1 @excludeit {@exclude_dirs} = (1) x @exclude_dirs; # this would be the subroutine used by File::Find sub findit { $File::Find::prune = 1 if $excludeit{$_}; # .. }