“使用 5.014”到底能实现什么功能?
请有人复制并粘贴到这里,因为我在任何 perldoc 中都找不到它。 (也许我是瞎子)。在“perldoc 功能”中,只有 5.10 的一些内容。或者给我指向某个网址。
谢谢。
编辑:
请先检查一下,您回复了什么。例如:试试这个:
use 5.008;
$s=1;
say "hello";
您将收到有关“say”的错误消息,因为 perl 5.8 不识别“say”
之后,试试这个:
use 5.014;
$s=1;
say "hello";
你会得到错误
Global symbol "$s" requires explicit package name
因此,“使用 5.014”启用 使用严格
,以及使用功能“say”
; - 默认。
最佳答案
此外what raj correctly said有关在旧版 Perl 中使用 use 5.014
时收到的错误消息,您可以阅读 source code of 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)],
);
严格位部分埋藏在解释器本身的代码中更深一些。如果你查看 pp_ctl.c
for tag 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);
}
关于Perl: 'use 5.014' 启用了哪些具体功能?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6410492/