我试图遵循一些例子在下面的一段代码中使用智能匹配,但失败了(没有被过滤掉)。我如何在这里使用智能匹配来同时匹配多个正则表达式?如何使用Perl的智能匹配一次匹配多个模式?
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;
}
}
的可能重复[如何在Perl中匹配多个正则表达式?](http://stackoverflow.com/questions/3694322/how-to-match-against-multiple-regexes-in-perl) – 2010-09-16 07:47:50