我是Perl的新手,当我尝试使用哈希时,编译器会给我一个语法错误。 这就是问题所在:
while (<>){
@words_in_line = /[a-z](?:[a-z']*[a-z])?/ig;
foreach $word (@words_in_line){
%wordcount{$word}++;
}
}
我得到的错误是
syntax error at ./wordfreq.pl line 11, near "%wordcount{"
syntax error at ./wordfreq.pl line 11, near "++;"
syntax error at ./wordfreq.pl line 13, near "}"
Execution of ./wordfreq.pl aborted due to compilation errors.
答案 0 :(得分:7)