“使用5.014”到底是什么功能?
拜托,有人在这里复制和粘贴,因为我在任何文件中都找不到它。(也许我是瞎子)。在“perldoc特性”中,只有5.10中的一些内容。或者给我指个网址。
谢谢。
编辑:
请先检查一下,您回答什么?例如:尝试如下:
use 5.008;
$s=1;
say "hello";您将得到关于"say“的错误消息,因为Perl5.8不知道"say”
之后,试试这个:
use 5.014;
$s=1;
say "hello";你会犯错误的
Global symbol "$s" requires explicit package name 因此,"use 5.014“启用 use strict和use feature 'say';-(默认情况下为)。
发布于 2011-06-20 12:05:43
除了拉杰正确地说了什么关于如果将use 5.014与旧版本的feature一起使用时会收到的错误消息,您可以找到一个已启用阅读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)],
);严格的位部分在解释器本身的代码中隐藏得更深一些。如果你调查一下标记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);
}发布于 2011-06-20 12:03:23
use x.x.x务实启用了一些特性,并且很容易测试这个特性:
#!/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.但是,我不能100%确定在5.14.0时打开了哪些功能。我相信你得到了say,state,switch,unicode_strings和strict。
发布于 2011-06-20 12:06:33
在较新的Perls (我认为从5.10开始)中,use 5.x通过5.12 & 5.14的perldeltas进行隐式use feature ':5.x'读取,我在5.12中看到了与unicode相关的特性,但在5.14中似乎没有添加任何新的内容。
https://stackoverflow.com/questions/6410492
复制相似问题