Perl:“使用 5.014"启用了哪些确切功能? [英] Perl: What exact features does 'use 5.014' enable?

查看:45
本文介绍了Perl:“使用 5.014"启用了哪些确切功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 5.014"究竟会启用什么?

What exactly does 'use 5.014' enable?

拜托,有人在这里复制并粘贴,因为我无法在任何 perldoc 中找到它.(也许我瞎了).在 'perldoc 功能' 中只有 5.10 的一些东西.或者将我指向某个 URL.

Please, someone copy&paste here, because i was not able find it in any perldoc. (maybe i'm blind). In the 'perldoc feature' are only some things for the 5.10. Or point me to some URL.

谢谢.

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

Please first check, what do you reply. For example: try this:

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

您将收到有关say"的错误消息,因为 perl 5.8 不知道say"

You will get error message about the "say", because perl 5.8 doesn't know "say"

之后,试试这个:

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

你会得到错误

Global symbol "$s" requires explicit package name 

因此,使用 5.014"启用 使用严格,以及使用功能说";- 默认.

so, the "use 5.014" enabling use strict, and use feature 'say'; - by default.

推荐答案

除了 关于错误消息 raj 正确说的内容如果在旧版本的 Perl 中使用 use 5.014,您会收到,您可以在阅读 feature 的源代码.相关部分靠近顶部:

Besides what raj correctly said about the error messages you'd receive if using use 5.014 with an older version of Perl, you can find a list of features enabled reading the source code of feature. The relevant part is near the top:

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)],
);

严格位部分在解释器本身的代码中隐藏得更深一些.如果您查看 /code> 用于标记 v5.11.0:

The strict bit part is buried somewhat deeper in the code for the interpreter itself. If you look into 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:“使用 5.014"启用了哪些确切功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆