Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^7: $VERSION in module files

by hippo (Bishop)
on Mar 27, 2020 at 11:00 UTC ( [id://11114714]=note: print w/replies, xml ) Need Help??


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

CPAN clients do a "static" parse (really a single line execution) to check the installed version of a module.

That's interesting and certainly news to me (++). I take it you mean that they do something like a grep for '\$VERSION\s*=' and then execute that line/statement in isolation? It's obvious how that would fail for anything but the simplest cases. Is this documented anywhere?

With your knowledge of these clients, is there any solution to maintaining a uniform version number across multiple modules in a single dist other than just brute-force updates of static scalar values?

Update: To answer my own question, see https://metacpan.org/pod/distribution/ExtUtils-MakeMaker/lib/ExtUtils/MakeMaker/FAQ.pod#Generating-*.pm-files-with-substitutions-eg-of-$VERSION which has a solid-looking answer, if not perhaps the most elegant. I will have a play with this but it looks like it might be a winner.

Replies are listed 'Best First'.
Re^8: $VERSION in module files
by haukex (Archbishop) on Mar 27, 2020 at 11:39 UTC
    I take it you mean that they do something like a grep for '\$VERSION\s*=' and then execute that line/statement in isolation?

    I just checked, cpanm uses Parse::PMFile, its _parse_version is fairly complex*, and its code apparently borrows from PAUSE::pmfile, the latter of course being the indexer for pause.perl.org. Then there's Module::Info's version, which borrows its code from ExtUtils::MM_Unix... I suspect there's probably a couple more variations on this kind of code out there.

    * Its comments also show some very interesting ways some modules set their versions: my $version = atan2(1,1) * 4; $Acme::Pi::VERSION = substr("$version", 0, 16); :-)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2024-04-16 11:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found