小编swi*_*bhs的帖子

wordlist.pl第11行的perl语法错误,靠近")$ fh"

my $fn= "words.txt";
open ($fn), $file;
if (! -e "$fh") $fh="STDIN";
while (<$fn>){;
    my $total_words = @words; #All word count
    my %count;
    $count{$_}++ for @words; # Here are the counts
    my $uniq_words  = scalar keys %count; # Number of uniq words
}
# Print sorted by frequency

print "$_\t$count{$_}" for (sort { $count{$b} <=> $count{$a} } keys %count);

close FILE;
exit 0
Run Code Online (Sandbox Code Playgroud)

我收到这个错误:

Scalar found where operator expected at wordlist.pl line 8, near ") $fh"
        (Missing operator before $fh?)
syntax …
Run Code Online (Sandbox Code Playgroud)

syntax perl scalar operator-keyword

1
推荐指数
1
解决办法
320
查看次数

标签 统计

operator-keyword ×1

perl ×1

scalar ×1

syntax ×1