我试图按照一些示例在以下代码中使用智能匹配,但失败了(没有过滤掉任何内容)。如何在此处使用智能匹配一次匹配多个正则表达式?
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;
}
}