我想知道是否有找到存在于具有特殊类型的文件夹中的文件数量。例如,我有一个带有* .txt,* .doc和html扩展名的30个文件的文件夹。我想知道这个目录中的say html文件的数量。计算perl中特殊类型的目录中的文件数
更新:这里是我作为一个数字os文件在目录中。但我不知道如何使用3210。当然,而不是getcwd
可以给出另一个参数。
use Cwd;
my $dir = getcwd;
my $count = 0;
opendir (DIR, $dir) or die $!;
my @dir = readdir DIR;
my @file_list;
if (@file_list eq glob "*.pl"){
print "$item\n";
$count = $count + 1;
}
closedir DIR;
$count = $count - 2;
print "There are $count files in this directory.";
http://perldoc.perl.org/functions/glob.html –
是的,有一种方法。 – melpomene
显示你的尝试。 – Jens