use strict;
use File::Find;
print "input your dir here: \n";
chomp(my $dir = <STDIN>);
print "counting,please waiting...\n";
find(\&wanted,$dir);
my $line_count;
sub wanted{
if(-f $_){
my $file = $_;
open(FILE,"<",$file) or die "Can't open $file $!\n";
$line_count++ while(<FILE>);
close(FILE);
}
}
print "Alother $line_count lines in $dir \n";
system("pause");

本文介绍了一个简单的Perl脚本,用于递归地遍历指定目录及其子目录中的所有文件,并统计每个纯文本文件的行数。该脚本适用于需要快速了解项目规模或文件内容长度的情况。

被折叠的 条评论
为什么被折叠?



