我正在尝试列出仅在目录./a/b
或./a/d
. 现在我明确指定使用(-d && $_ =~ "b") || (-d && $_ =~ "d")
. 有什么办法可以将所需的文件夹放入数组中?
use File::Find;
my $filename = "h*.txt";
print ("Now it's:", $filename);
find({
wanted => \&wanted,
preprocess => \&dir_preprocess,
}, './a');
sub dir_preprocess {
my (@entries) = @_;
#my @tmparr=("d","b"); This isn't working
if ( $File::Find::dir eq './a' ) {
@entries = grep { (-d && $_ =~ "b") || (-d && $_ =~ "d") }@entries;
}
return @entries;
}
my @mylist;
sub wanted{
if($_ =~ $filename) {
push(@mylist, $_);
}
}
print ("It's:", @mylist);