lima1 has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

what's the best way to implement the $VERSION number in module distributions with multiple packages? I looked in the code of several CPAN modules and found different strategies:

How would you do this? Thanks!

Update: Changed title.

  • Comment on $VERSION in modules with multiple packages

Replies are listed 'Best First'.
Re: One global $VERSION number in modules
by adrianh (Chancellor) on Aug 24, 2007 at 19:39 UTC
    • define $VERSION in all packages, sync them in all files before release
    • define $VERSION in all packages, but these are internal version numbers (update only when package changes)

    I personally prefer one of these two. I dislike distributions where modules don't have a set version, or inherit one from a base package.

    This is due to the (unfortunately) many times where I've been faced with the contents of an @INC that's been an unholy mixture of different modules form different distributions. Being able to track down the version numbers of different modules has been a godsend in those instances - and a complete pain when absent.

Re: One global $VERSION number in modules
by dsheroh (Monsignor) on Aug 24, 2007 at 20:14 UTC
    I tend towards the second and third options. Each file has its own version number which gets bumped, e.g., from 1.0.0 to 1.0.1 each time it's modified. Once I'm ready to issue the next release, I sync all version numbers to 1.1.0 and go from there for further changes.

    Aside from this generally making sense to me, it makes it easy when a client reports a problem that I thought I fixed last week - "What version of Foo::Bar.pm are you using?" "1.0.1" "Still? I sent you 1.0.4 last night... Here's a fresh copy of it." - without having to start diffing his version of the code against mine or hoping I notice that it's a stale version before spending too much time trying to isolate the "new" bug.

Re: One global $VERSION number in modules (TCBOO)
by tye (Sage) on Aug 24, 2007 at 16:08 UTC

    I would do (and have done) the first option. If there was some strong reason to have version numbers defined in multiple packages, then I'd have Some::Package::Version which simply defines the version number and exports it using Exporter; I wouldn't use inheritance. But I find that an unlikely feature requirement, especially since you mention inheritance.

    - tye