Modules are cool especially when they come with versioning. You can define minimum module version to prevent leak of methods you want to use. But with every light side there comes a dark side which means Perl's TIMTOWTDI.
After nearly seven years as a Perl developer I saw and wrote version declarations in many ways. Some are easily to point as bad, some not. As no one can know a language completely I would like to ask you guys whats the pros and cons of the following software versioning in Perl is.
Please don't hesitate to comment more ways of version definition if you find one leaking ;)
Please respect:
What are the pros and cons about declaring package version methods in Perl?
Method 1
package PackageName;
BEGIN {
use version 0.77; our $VERSION = version->new('v0.0_1');
}
Method 2
package PackageName;
BEGIN {
our $VERSION = 0.000_01;
}
Method 3
package PackageName;
BEGIN {
our $VERSION = 0.0.1;
}
Method 4
package PackageName;
use version 0.77; our $VERSION = version->new('v0.0_1');
Method 5
package PackageName;
our $VERSION = 0.000_01;
Method 6
package PackageName;
our $VERSION = 0.0.1;
The correct answer is, do this:
package My::Thing;
our $VERSION = "0.001";
The version should always be a decimal number, using the three-digit split convention. The above version would be shortened to v0.1.0, to change the 3rd step in that abbreviated form you would define your version like this: 0.001001
, which would be v0.1.1 abbreviated.
Do not put underscores into your version number to mark dev releases. The Perl toolchain has since adopted the -TRIAL mechanism, as exemplified by Dist::Zilla 4.101800-TRIAL. The advantage of that is that the version numbers in your code need no changes. Only the release filename and meta files are modified from the norm by adding -TRIAL.
Edit:
After reading daxim's answer and pondering a bit, i have to agree on putting the version number in quotes. It does not change the functionality in any way, but reduces the chances of 0.00101
being mistaken for v0.1.1
, when it is in fact v0.1.10
and is more clearly read as 0.001010
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With