Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is setting $VERSION good for?

Tags:

perl

Lot's of ways to set your modules $VERSION in perl, some even have advantages. What I don't know is why we do it? I mean the META.yml has a version... which is what cpan uses? so why do we set it in the module? what's the point?

like image 474
xenoterracide Avatar asked Nov 29 '22 11:11

xenoterracide


2 Answers

So you can say

use Module::Name 4.5.6;

And the code will fail if you don't have at least version 4.5.6 of Module::Name installed.

It is also helpful when you need to know what version is installed, you can just say:

perl -MScalar::Util=99999999999999

This is roughly equivalent to

#!/usr/bin/perl

use Scalar::Util 99999999999999;

It will fail (becuase Scalar::Util is nowhere near version 99999999999999) and tell you the version number. In my case it says:

Scalar::Util version v.Inf required--this is only version 1.22 at
/Users/cowens/apps/perlbrew/perls/perl-5.12.1/lib/5.12.1/Exporter/Heavy.pm
line 120.
BEGIN failed--compilation aborted.
like image 113
Chas. Owens Avatar answered Dec 31 '22 15:12

Chas. Owens


From perlmodlib: Guidelines for Module Creation:

To be fully compatible with the Exporter and MakeMaker modules you should store your module's version number in a non-my package variable called $VERSION.

To supplement the Answers given by others, here is the link to use MODULE VERSION

like image 24
toolic Avatar answered Dec 31 '22 16:12

toolic