声明要使用哪个版本的Perl的现代方法是什么? [英] What's the modern way of declaring which version of Perl to use?

查看:121
本文介绍了声明要使用哪个版本的Perl的现代方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

说到我们的脚本需要哪个版本的Perl时,我们有选择,哦,兄弟,我们有选择:

When it come to saying what version of Perl we need for our scripts, we've got options, oh, brother, we've got options:

use 5.010;
use 5.010_001;
use 5.10.0;
use v5.10;
use v5.10.0;

似乎一切正常.高丽主义者抱怨除了头两个. (不幸的是,v字符串似乎存在这样的缺陷,因为Perl 6希望您为Perl 6脚本执行use v6; ...)

All seem to work. perlcritic complains about all but the first two. (It's unfortunate that the v strings seem to have such flaws, since Perl 6 expects you to do use v6; for your Perl 6 scripts...)

那么,我们应该怎么做才能表明我们要使用特定版本的perl?

So, what should we be doing to indicate that we want to use a particular version of perl?

推荐答案

实际上只有两个选项:十进制数字和v字符串.使用哪种形式部分取决于要有意义"的错误消息(而不是语法错误)支持"的Perl版本. (在Perl 5.6中添加了v-string语法.)公认的最佳实践-这是perlcritic强制执行的-是使用十进制表示法.您应该指定脚本正常运行所需的Perl最低版本.通常,这意味着声明依赖于主要版本中添加的语言功能,例如使用5.10中添加的say函数.如果脚本正常运行很重要,则应包括补丁程序级别.例如,我的某些代码指定了use 5.008001,因为它取决于5.8.0中已修复5.5.8中的错误的修复程序.

There are really only two options: decimal numbers and v-strings. Which form to use depends in part on which versions of Perl you want to "support" with a meaningful error message instead of a syntax error. (The v-string syntax was added in Perl 5.6.) The accepted best practice -- which is what perlcritic enforces -- is to use decimal notation. You should specify the minimum version of Perl that's required for your script to behave properly. Normally that means declaring a dependency on language features added in a major release, such as using the say function added in 5.10. You should include the patch level if it's important for your script to behave properly. For example, some of my code specifies use 5.008001 because it depends on the fix for a bug that 5.8.0 had which was fixed in 5.8.1.

这篇关于声明要使用哪个版本的Perl的现代方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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