How do you specify a package version in Perl?

孤者浪人 提交于 2019-12-04 07:32:22
ire_and_curses

Your quote from Perl Best Practices is not quite right. Specifically, bare vstrings of the form

our $VERSION = v1.0.3;

are discouraged. In the latest version of version.pm, the recommendation is to use true strings:

use version 0.77; our $VERSION = qv("v1.2.3");               # shorthand

This functionality has been added to aid readability, while specifically avoid the traps of bare strings described here.

As the doc page you linked to says, you can use versions without the pre-pending 'v' using built-in logic in Perl 5.10:

If you have a module that uses a decimal $VERSION (floating point), and you do not intend to ever change that, this module is not for you. There is nothing that version.pm gains you over a simple $VERSION assignment.

So the answer to your question is: use the new "v1.0.3" syntax if you are writing new code that uses version.pm. Stick to a plain number if that is how your old code was written, or if you don't want to depend explicitly on module.pm.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!