0
我刚刚开始通过Modern Perl学习Perl,但其中一个例子让我感到沮丧。书中有这样的代码:语法错误读取和反转STDIN
while (<>)
{
chomp;
say scalar reverse;
}
运行这段代码的命令perl stdin.pm hi.txt
或cat hi.txt | perl stdin.pm
给了我这个错误:
syntax error at stdin.pm line 4, near "say scalar"
Execution of stdin.pm aborted due to compilation errors.
的hi.txt
内容是:
hi
how
are
you
我是什么做错了?
感谢您的快速答复!到目前为止,我在其他Perl脚本中实际上已经使用了Modern :: Perl;在这一段中,我只是忘记了它。 –