Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

Re^2: Seeking thoughts on version numbers in modules

by xdg (Monsignor)
on Dec 27, 2004 at 18:19 UTC ( #417597=note: print w/replies, xml ) Need Help??

in reply to Re: Seeking thoughts on version numbers in modules
in thread Seeking thoughts on version numbers in modules

Great comments. #5 is intriguing and I poked around a little to investigate. It looks like CPAN (er., anyway) maintains version numbers on all files, but only if they exist. And the version of individual files can bear little/no relation to the distribution version. Compare these:

I wonder if the version number for the distribution that CPAN uses even comes from a file at all or simply from the distribution tar file numbering (or a META.yaml file, if it exists). If the latter is true, you could manually set your version in a Makefile.PL or Build.PL and have no VERSION in your files at all.

The only downside I see to this (and to leaving version numbers out of submodules) is that you lose version checking ability. If a distribution contains a "main" module and submodules that would never be directly used, then it won't really matter if you only have a VERSION in your main module file. On the other hand, if a distribution contained modules which could be used independently, then it does matter.

See Test-Simple for an example where this might be the case. (It's not, for reasons I'll explain, but bear with as an example.) Test::Builder's version is out of sync at 0.22 compared to 0.54 for distribution as a whole. In a Makefile.PL or Build.PL, if my list of pre-requisites had Test::Builder => 0.22, and Test::Builder's version number hadn't been updated in a while, I could pass the pre-req with an old version of Test::Builder, even though the distribution version number of the Test-Simple distribution had been updated. It turns out in this case, that Michael does actually increment Test::Builder's number when it changes, but only when it changes and not just because Test::More or Test::Simple or the distribution version number change.

This may suggest a general good practice of using the same module in a prerequisites statement as is being used to generate the version number for the distribution, just in case the distribution author isn't as diligent about maintaining all the version numbers.


Code posted by xdg on PerlMonks is public domain. It has no warranties, express or implied. Posted code may not have been tested. Use at your own risk.

Replies are listed 'Best First'.
Re^3: Seeking thoughts on version numbers in modules
by dragonchild (Archbishop) on Dec 27, 2004 at 18:24 UTC
    It's funny you mention Excel::Template because I'm the author. I actually deliberately removed version numbers from the individual files because I wanted to have a version number for the release. The individual files don't matter as much as the functionality from the release itself.

    I wonder if the version number for the distribution that CPAN even comes from a file at all or simply from the distribution tar file numbering (or a META.yaml file, if it exists).

    In your Makefile.PL (or Build.PL, I suppose), there is an item called VERSION_FROM or VERSION. If you have a VERSION, CPAN uses that. If you have a VERSION_FROM, CPAN goes into that file and looks for the first $VERSION line. (It's a little more complicated than that, but you get the idea.) This is all documented in ExtUtils::MakeMaker (and, I'm sure, in Module::Build).

    Being right, does not endow the right to be rude; politeness costs nothing.
    Being unknowing, is not the same as being stupid.
    Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
    Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.

      This is kind of a reply to both of you. CPAN has an item entitled "Finding packages and VERSION", in which it lists
      perl -MExtUtils::MakeMaker -le \ 'print MM->parse_version(shift)' filename
      If you are author of a package and wonder if your $VERSION can be parsed, please try the above method.

      CPAN::DistnameInfo - Extract distribution name and version from a distribution filename.

      MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
      I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
      ** The third rule of perl club is a statement of fact: pod is sexy.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://417597]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2020-03-29 22:44 GMT
Find Nodes?
    Voting Booth?
    To "Disagree to disagree" means to:

    Results (171 votes). Check out past polls.