我想知道是否有找到存在於具有特殊類型的文件夾中的文件數量。例如,我有一個帶有* .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