Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does every Perl module in a distribution need to have a version number?

I'm maintaining a CPAN distribution that has over 100 .pm files. Do each of them need to have a $VERSION, or is it okay to just include it in the main module?

For the other modules in the distribution, what effect does including or not including the $VERSION have?

In case it's relevant to the question, people should only be "use"-ing the main module in this distribution. And, for the purpose of this question, I'm not asking about how it should be specified in any file, just whether or not it's present in any form.

like image 666
Steve Simms Avatar asked Jan 21 '13 02:01

Steve Simms


1 Answers

Empirically, lots of modules don't put the version number in every .pm file. If you do a snapshot bundle (b in cpanp) and look at the generated file, you'll see that. On my machine, the snapshot for Perl 5.16.2 with lots of modules added contained 7962 modules, but 2070 of those included 'undef' as the version (so roughly 1 in 4 has undef as the version).

Personally, I don't like that, so all the .pm files in my module — DBD::Informix — are version stamped with the same version in each release (the current release is 2013.0118, and all the .pm files are stamped with 2013.0118 as the version number), but there are lots of modules (people) that do it otherwise.

  • You do not have to provide a version number for every .pm file.
  • On the whole, it is better if you do in fact provide a version number for every .pm file.
  • I think it is sensible to provide the same version number for all .pm files in a distribution.

In my view, the worst problems come when a module is updated but some bit isn't, so CPANPLUS thinks the module is out of date even though installing the latest version doesn't change anything. I've got 5 modules like that at the moment, and I'm sorely tempted to delete them all, especially since I'm not really using them. (Sometimes, that's triggered by a file being installed in a new location, but I don't think that's the only cause. I'm not sure what else triggers it, but it is a problem that occurs periodically.)

like image 56
Jonathan Leffler Avatar answered Oct 08 '22 05:10

Jonathan Leffler