请问我这个程序有啥问题。执行下来,wordlist里面是空白。请哪位朋友指点一下。
!/usr/bin/perl
open (FH, 'F:\\perl\about BUCT.txt ') || die $!;
open (OUT,'>>','F:/perl/wordlist.txt')or die $!;
sub byDescendingValues{
$value= $freq{$b}<=>$freq{$a};
if ($value==0){
return $a cmp $b;
}else{
return $value;
}
}
while(<FH>) {
{$line=$_ ;
chomp $line;
@words = split (/[\.\?,!;:]+\s+/, $line);}
foreach $x (@words) {
++ $wordfreq{$x};
}
}
close FH;
foreach $x(sort byDescendingValues keys %freq){
print OUT "$x,$wordfreq{$x}\n";
}