Perl:“使用5.014”启用了哪些确切功能?

时间:2011-06-20 11:32:38

标签: perl

“使用5.014”启用了什么?

请有人复制并粘贴在这里,因为我无法在任何perldoc中找到它。 (也许我是盲目的)。在'perldoc功能'中只有5.10的一些东西。或者指出一些网址。

感谢名单。

编辑:

请先检查,你有什么回复。例如:试试这个:

use 5.008;
$s=1;
say "hello";

您将收到有关“说”的错误消息,因为perl 5.8不知道“说”

之后,试试这个:

use 5.014;
$s=1;
say "hello";

你会收到错误

Global symbol "$s" requires explicit package name 

所以,“使用5.014”启用 use strictuse feature 'say'; - 默认情况下

3 个答案:

答案 0 :(得分:27)

除了what raj correctly said关于使用use 5.014旧版本Perl时收到的错误消息,您还可以找到已启用的功能列表,阅读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);
}

答案 1 :(得分:4)

use x.x.x pragma 确实启用了一些功能,并且很容易对此进行测试:

#!/usr/bin/env perl
use warnings;
use 5.14.0;

say "hello world!"

运行得很好;输出“你好世界!”。

#!/usr/bin/env perl
use warnings;
# use 5.14.0;

say "hello world!"
火焰死亡;输出此错误消息:

Unquoted string "say" may clash with future reserved word at foo line 5.
String found where operator expected at foo line 5, near "say "hello world!""
    (Do you need to predeclare say?)
syntax error at foo line 5, near "say "hello world!""
Execution of foo aborted due to compilation errors.

但是,我不确定从5.14.0开启哪些功能。我相信您会得到saystateswitchunicode_stringsstrict

答案 2 :(得分:4)

在较新的Perls中(我认为从5.10开始)use 5.x执行隐式use feature ':5.x'读取5.12&的perldeltas 5.14,我在5.12中看到了一个与unicode相关的功能,但5.14中似乎没有添加任何新内容。