Module...ERSION(3pm)
β¨ NAME β¨
Module::Extract::VERSION β it pulls a module's version out of its source code, and it does it safely π
(this is a 3pm page from the User Contributed Perl Documentation, bestie, so it's a Perl module manual, and we are gonna read it together)
πΈ SYNOPSIS πΈ
use Module::Extract::VERSION;
my $version # just the version
= Module::Extract::VERSION->parse_version_safely( $file );
my @version_info # extra info
= Module::Extract::VERSION->parse_version_safely( $file );
π DESCRIPTION π
Okay so picture this: you've got module source code, and buried in there somewhere is the version number. This module's whole job is fishing that version number out for you. β¨
It assumes two things, and you need to know them, no cap:
- there is only one
$VERSIONin the file - the entire
$VERSIONstatement lives on one single line
π§ Class methods
$class->parse_version_safely( FILE );β hand it a module file, get the module version back. It works exactly the same way"mldistwatch"in PAUSE works. The vibe: it finds the one line holding the$VERSIONstatement, extracts it,evals it inside a Safe compartment, and returns whatever comes out. π«Ά
Now here's the context tea, because it matters:
- In scalar context, you just get the version as a string. Simple. Iconic.
- In list context, you get a whole list of goodies:
sigil
fully-qualified variable name
version value
file name
line number of $VERSION
π¦ SOURCE AVAILABILITY π¦
This code lives on Github, go be nosy:
https://github.com/briandfoy/module-extract-version.git
π AUTHOR π
brian d foy, "<briandfoy@pobox.com>"
Real talk though, some of this code was stolen from "mldistwatch" in the PAUSE code by Andreas KΓΆnig β but our guy moved most of it around, so it's a remix. π
And shoutout to Andrey Starodubtsev, who added code to handle the v5.12 and v5.14 "package" syntax. The way that syntax needed handlingβ¦ ate. π
π COPYRIGHT AND LICENSE π
Copyright Β© 2008-2026, brian d foy "<briandfoy@pobox.com>". All rights reserved.
You may redistribute this under the Artistic License 2.0. Periodt.
friendly little reminder bestie: it needs exactly one $VERSION and that whole statement has to sit on a single line, or this whole thing gets sad π
stay slay, run your version checks, and remember β this page is perl v5.40.1, dated 2026-06-21, and it's the Module::Extract::VERSION 3pm manual π
π¦ where this page comes from
- ubuntu stonking: libmodule-extract-version-perl 1.121-1 Β· Artistic-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms