来源:linux宝库作者:linux宝库 发布时间:2007-09-30 00:00:00

#!usr/bin/perl
if ( $#ARGV<2 ) {
print<<"EOF";
输入参数不够,您输入的格式应该是:
perl $0 要搜索的字符串 搜索文档列表 记录文档
EOF
exit 0;
}
$string=shift;
$logfile=pop;
while(<>){
print "现在处理文档 $ARGV ... n" if ($currentFile ne $ARGV);
chomp($_);
foreach $word(split(/ /,$_)){
$couter++ if ($word eq $string);
}
$currentFile=$ARGV;
}
print "$string 出现的总次数是: $couter ";
open(FILE,">>$logfile");
print FILE "#"x30,"n";
print FILE "$string 出现的总次数是: $couter ";
close FILE;
|
还没有关于此文章的相关评论!