http://www.perlmonks.org?node_id=758859


in reply to <pkg>::VERSION, git, hashes, shipit, Class::MOP, Moose, perl core support - what NOW makes sense.

You could make a module part of your distribution whose job is only to hold the distribution version number.

package Your::Dist::Version; # note no strict $VERSION = 1.23; sub import { my $pkg = caller; ${ "$pkg\::VERSION" } = $VERSION; } 1;

Then use Your::Dist::Version from every module in the distribution. Everything that does has the One True Version inserted into its namespace. You can change it in one place and keep other info in that one file as convenient.

Replies are listed 'Best First'.
Re^2: <pkg>::VERSION, git, hashes, shipit, Class::MOP, Moose, perl core support - what NOW makes sense.
by otto (Beadle) on Apr 21, 2009 at 20:44 UTC

    Another way is to make the top-level module more akin to a base of the whole dist, which in some manners it is. Then others inherit the version. Class::MOP::Object provides dump for everything ...

    At issue is to examine and dissect what really is the use of ::VERSION for each of the concepts of file, module, package, and distribution. These are all very different, but often are used interchangeably due to some of the syntactic sugar applied to them. Dealing with versioning means you really need to carefully examine the distinctions

Re^2: <pkg>::VERSION, git, hashes, shipit, Class::MOP, Moose, perl core support - what NOW makes sense.
by JavaFan (Canon) on Apr 21, 2009 at 22:11 UTC
    Then use Your::Dist::Version from every module in the distribution. Everything that does has the One True Version inserted into its namespace.
    But it won't work.

    The CPAN indexer searches for lines in modules that seems to set the VERSION number, extracts that line, and executes it. Just that line. Nothing more. Any clever tricks you'd like to use will work at run time (for instance, if someone does use Module VERSION;), but the important part, the CPAN indexer, won't be able to find the version number.

      Sorry if that might seem ignorant, but why is that a problem? Can't the CPAN indexer simply take the version from the META.yaml and take that as a default version?

      Then all you have to do is to make sure that the meta data and Your::Dest::Version agree.