【发布时间】:2016-05-12 10:56:47
【问题描述】:
这个问题可能很愚蠢。但我刚刚开始探索 Perl。我正在使用 Perl v5.16.2。我知道say语句已经在5.10中引入了。
#!/usr/bin/perl
say "Hello World!";
当我尝试运行上面的程序时,我收到以下错误:
$ ./helloPerl
String found where operator expected at ./helloPerl line 3, near "say "Hello World!""
(Do you need to predeclare say?)
syntax error at ./helloPerl line 3, near "say "Hello World!""
Execution of ./helloPerl aborted due to compilation errors.
但是当我添加语句 use 5.016; 时,它给了我正确的输出。
#!/usr/bin/perl
use 5.016;
say "Hello World!";
我的疑问是,我使用的是 perl v5.16.2,它高于 5.010。为什么我要在这里使用use 声明来提及 Perl 版本?
【问题讨论】:
标签: perl