in reply to Re: Perl usage (version number)
in thread Perl usage

from perlmod (v5.14)
# set the version for version checking $VERSION = 1.00; # if using RCS/CVS, this may be preferred $VERSION = sprintf "%d.%03d", q$Revision: 1.1 $ =~ /(\d ++)/g;

compare CVS revisions

So its a way to generate a module's $VERSION number from the version control system's revision number.

...well...

Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Je suis Charlie!

Replies are listed 'Best First'.
Re^3: Perl usage (version number)
by dsheroh (Monsignor) on Nov 23, 2015 at 08:21 UTC
    Ah, yes, right... That shook loose some ancient information, from back when I was using CVS.

    As I recall, CVS has some magic such that $Revision nnn$ will be automatically updated, replacing nnn will the current CVS revision number each time you check the file in.

    The rest of the code is to extract the number from the string $Revision nnn$ and reformat it so that each number (after the first) is displayed as two digits. So $Revision 1.2.3.4.5$ becomes 1.02.03.04.05.

      > So $Revision 1.2.3.4.5$ becomes 1.02.03.04.05.

      well , yes, except it doesn't

      DB<30> p $VERSION = do { my @r = (q$Revision: 1.2.3.4.5 $ =~ /\d+/g) +; sprintf "%d."."%02d" x $#r, @r }; 1.02030405

      That's what I meant with different version formats and potential bug.

      IMHO $VERSION is supposed to be a float which can be compared numerically with < , == and >.

      There is some mention of a version object, but this seems to be restricted to Perl's own Version.

      DB<34> use Data::Dump qw/dd/ DB<35> dd $] 5.016003 DB<36> dd $^V bless({ original => "v5.16.3", qv => 1, version => [5, 16, 3] }, +"version")

      Cheers Rolf
      (addicted to the Perl Programming Language and ☆☆☆☆ :)
      Je suis Charlie!

        Ouch... Yes, I was a bit too hasty and assumed the actual output would be in the format I expected it to generate. Thanks for correcting my mistake!