Module versions in multi-module distributions

If a distribution contains multiple modules, how should VERSION be set in each module?

There are a number of options:

  • Every module has the same version number, and it's the version number of the dist.
  • Each module has its own version number. The version number of the dist might be different from all of them, or it might be take from the lead module, if there's an obvious one.
  • The lead module has a version number defined, but none of the other modules have a version defined.

The first option makes most sense to me, and until recently I thought it was the approach most people follow. Sure, it's a pain updating version number in every module for every release, but Dist::Zilla (and other tools?) can handle this for you automatically.

I can see at least one problem with the second option: you might be using one module from the distribution, and keeping an eye on the latest version, perhaps via MetaCPAN. A new version of the distribution might be released, with the module you use unchanged, but with changes (eg bug fixes) in other modules, which are used by the one you use.

The problem I see with the third approach is that you might only be interested in one module, but you can't just track whether you've got the latest version of that.

Ok, there are a number of ways you can map a module to distribution, and then just check that you've the latest version of a distribution.

I'm just curious: what are other pros and cons for each approach (and others I've missed?), and the reasons why people pick one approach over the others?


Hi Neil

This problem bugged me for a long time, although I've always believed the same version # should be in all *.pm files.

One day I decided to adopt the convention of formatting the version statement in exactly the same way in every module, and then wrote a little program which takes 2 params: (1) The directory (and all sub-dirs) to process, and (2) The version #. Then I just jam that # into all files, making sure I include the test scripts and test modules, and any other scripts I ship.

I can't understand the rationale behind having different version #s in different files, since the whole distro gets shipped at the same time, no matter which file get updated.

The simplest, cleanest approach - uniformity - is the one which appeals to me.


perl-reversion is a very handy script for changing the version numbers on a collection of modules. (Hell, I use it even if I'm just bumping the version number for a single module!)

It comes as part of the Perl-Version distribution.

+1 for perl-reversion. I used to use a combination of `ack` and `perl -E 's/.../.../'` to do the reversioning and someone (maybe Andy) mentioned it to me. Seriously easy. From then on, because you are using this nice tool, its easy to keep all the modules at the same version number as each other and increment for each release.

Leave a comment

About Neil Bowers

user-pic Perl hacker since 1992.