究竟什么'使用5.014'启用?
请有人复制并粘贴,因为我无法在任何perldoc中找到它.(也许我是盲目的).在'perldoc功能'中只有5.10的一些东西.或者指向一些URL.
感谢名单.
编辑:
请先检查,你有什么回复.例如:试试这个:
use 5.008;
$s=1;
say "hello";
Run Code Online (Sandbox Code Playgroud)
您将收到有关"说"的错误消息,因为perl 5.8不知道"说"
试试这个:
use 5.014;
$s=1;
say "hello";
Run Code Online (Sandbox Code Playgroud)
你会得到错误
Global symbol "$s" requires explicit package name
Run Code Online (Sandbox Code Playgroud)
所以,"使用5.014" 启用 use strict,和use feature 'say'; - 默认情况下.
lar*_*sen 27
除了raj正确地说明了如果使用use 5.014旧版本的Perl时收到的错误消息,你可以找到一个功能列表,阅读源代码feature.相关部分接近顶部:
my %feature_bundle = (
"5.10" => [qw(switch say state)],
"5.11" => [qw(switch say state unicode_strings)],
"5.12" => [qw(switch say state unicode_strings)],
"5.13" => [qw(switch say state unicode_strings)],
"5.14" => [qw(switch say state unicode_strings)],
);
Run Code Online (Sandbox Code Playgroud)
严格的位部分隐藏在解释器本身的代码中.如果你研究pp_ctl.c标签v5.11.0:
/* If a version >= 5.11.0 is requested, strictures are on by default! */
if (PL_compcv && vcmp(sv, sv_2mortal(upg_version(newSVnv(5.011000), FALSE))) >= 0) {
PL_hints |= (HINT_STRICT_REFS | HINT_STRICT_SUBS | HINT_STRICT_VARS);
}
Run Code Online (Sandbox Code Playgroud)