I was trying to follow some examples to use smart matching in the following piece of code, but failed (nothing was filtered out). How can I use smart matching here to match against multiple regexes at once?
my $regexes_to_filter_a = ("tmp", "temp", "del")
my @organism_dirs = (); # this will hold final list of dirs to processs
my @subdirs = File::Find::Rule->directory->maxdepth(1)->in($root_dir);
foreach my $subdir (@subdirs) {
my $filter = 0;
# IMPROVE: can do smart matching here
foreach my $regex ( @{$regexes_to_filter_a} ) {
if ( basename($subdir) =~ $regex ) {
$filter = 1; # filter out this dir
last;
}
}
unless ($filter) {
push @organism_dirs, $subdir;
}
}