Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^3: $VERSION in module files

by hippo (Bishop)
on Mar 26, 2020 at 11:14 UTC ( #11114668=note: print w/replies, xml ) Need Help??


in reply to Re^2: $VERSION in module files
in thread $VERSION in module files

Not necessarily. If you maintain a version number for the dist which applies also to all the modules then you can pick one master module which all the others use and have them set their versions from that one. eg.

package Foo; our $VERSION = '1.01'; # ... package Foo::Bar; use Foo; our $VERSION = $Foo::VERSION;

I never bother specifying version numbers in POD so you're on your own there. :-) Doubtless there's a way in Dist::Zilla but then you'd have $problems++

Replies are listed 'Best First'.
Re^4: $VERSION in module files
by Haarg (Curate) on Mar 26, 2020 at 12:55 UTC

    If you specify the module version like this, it won't be picked up by tools like ExtUtils::MakeMaker, and won't be properly indexed on CPAN by PAUSE. The version needs to be specified by a single line, and won't be able to load modules from the current distribution.

Re^4: $VERSION in module files
by haukex (Bishop) on Mar 26, 2020 at 12:25 UTC
    package Foo; our $VERSION = '1.01'; # ... package Foo::Bar; use Foo; our $VERSION = $Foo::VERSION;

    If that's in a single file that may work, I'm not sure, however, I suspect at least some of the tools that rely on a static parse won't be able to handle that.

      For the static parse I rely on the "provides" list in the metadata. For the above example the Makefile.PL includes something like this:

      my $release = '1.01'; my %MF = ( META_MERGE => { 'meta-spec' => { version => 2 }, provides => { 'Foo' => { file => 'lib/Foo.pm', version => $release }, 'Foo::Bar' => { file => 'lib/Foo/Bar.pm', version => $release }, }, }, # ... }; WriteMakefile (%MF);

      So the version is specified explicitly twice: once in the Makefile.PL and once in the master module. If there's a reliable way to specify it explicitly only once that would be good to know.

        "provides" isn't the only place versions are used. CPAN clients do a "static" parse (really a single line execution) to check the installed version of a module. If you specify versions in this way, the CPAN clients won't be able to check for upgrades or resolve dependencies on these modules correctly, and install tools like ExtUtils::MakeMaker will complain about missing dependencies.
Re^4: $VERSION in module files
by Anonymous Monk on Mar 26, 2020 at 21:23 UTC

    Not necessarily. If you maintain a version number for the dist which applies also to all the modules then you can pick one master module which all the others use and have them set their versions from that one. eg.

    inheriting a version number is like inheriting your fathers age/birthdate

    yeah my wife just gave birth to a beautiful baby, 9lbs, 32 years old

      Yes and no. It can also be like having different birthdays for your limbs. It might make sense for a peg leg, but mostly unnecessary.

      Depends on how interdependent the modules are.

        Yes and no. It can also be like having different birthdays for your limbs. It might make sense for a peg leg, but mostly unnecessary. Depends on how interdependent the modules are.

        Hi,

        If its mostly unnecessary, what would be the point of inheriting a version number? Just ask the head

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (None)
    As of 2021-10-17 16:31 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      My first memorable Perl project was:







      Results (72 votes). Check out past polls.

      Notices?