Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I declare the version number for a Perl module?

I thought I knew how to declare version numbers for modules. But after reading the article "$VERSION Confusion" at Modern Perl Books, a Modern Perl Blog; I'm now more confused than I started. (Ignorance was indeed bliss.) Not that I have hangups about "perfect" code but I'm just really curious why such a trivial matter apparently has no definitive answer for such a mature language.

Hope the SO community can find a definitive answer to this question as there are better things for Perl hackers to do than argue about different ways to declare version numbers.

like image 836
GeneQ Avatar asked Aug 24 '10 01:08

GeneQ


People also ask

What is Perl version?

Currently latest perl version is 5.24.


1 Answers

use Module VERSION

If the VERSION argument is present between Module and LIST, then the use will call the VERSION method in class Module with the given version as an argument. The default VERSION method, inherited from the UNIVERSAL class, croaks if the given version is larger than the value of the variable $Module::VERSION.

That makes for a straightforward pattern:

package MyModule;

our $VERSION = 1.23;

# ...

1;
like image 76
Greg Bacon Avatar answered Sep 28 '22 03:09

Greg Bacon