小编Pre*_*ick的帖子

具有哈希的Perl语法错误

我是Perl的新手,当我尝试使用哈希时,编译器给我一个语法错误.这就是问题所在:

while (<>){
    @words_in_line = /[a-z](?:[a-z']*[a-z])?/ig;
    foreach $word (@words_in_line){
            %wordcount{$word}++;
    }
}
Run Code Online (Sandbox Code Playgroud)

而我得到的错误是

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. 
Run Code Online (Sandbox Code Playgroud)

syntax perl

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

标签 统计

perl ×1

syntax ×1