views:

185

answers:

1

I'm a bit confused by conflicting advice between pre-5.10.0 documents and the more recent version module. Perl Best Practices makes it pretty clear that version strings ('v1.0.3') are bad and one is supposed to specify a version as follows:

use version; our $VERSION = qv('1.0.3');

but the version module says that we're back to using version strings:

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

Have we regressed, or is there a reason behind this?

+7  A: 

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.

ire_and_curses
The newest gospel is that vstrings of the form v1.0.3 as you give above are okay but REALLY BARE vstrings of the form 1.0.3 (two decimals, no v) are evil, evil, evil. This is straight from the perl5-porters.
tsee