V(3pm)
π¦ NAME π¦
okay bestie, so V is literally just here to print the version of the module(s) you specify. that's the whole gig. no cap.
β¨ SYNOPSIS β¨
the classic move:
$ perl -MV=V
or, if you're feeling extra and want more than one:
$ perl -MV=CPAN,V
and now it can also serve as a light-weight module for grabbing versions of modules without loading them:
require V;
printf "%s has version '%s'\n", "V", V::get_version ("V");
Starting with version 0.17, V will show all "package"s or "class"es in a file that have a version. if you wanna see all packages/classes from that file, set the environment variable PERL_V_SHOW_ALL to a true value. π
and if you want all available files/versions from @INC:
require V;
my @all_V = V::Module::Info->all_installed ("V");
printf "%s:\n", $all_V[0]->name;
for my $file (@all_V) {
my ($versions) = $file->version; # Must be list context
if (@$versions > 1) {
say "\t", $file->name;
print "\t %-30s: %s\n", $_->{pkg}, $_->{version} for @versions;
}
else {
printf "\t%-50s - %s\n", $file->file, $versions->[0]{version};
}
}
every element in that array isa V::Module::Info object, and each one comes with 3 attributes and a method β here's the lineup:
- attribute name β the package name.
- attribute file β full filename with directory.
- attribute dir β the base directory (from
@INC) where the package-file was found. - method version β this method will look through the file to see if it can find a version assignment in the file and uses that to determine the version. As of version 0.13_01, all versions found are passed through the version module.
As of version 0.16_03 we look for all types of version declaration:
package Foo;
our $VERSION = 0.42;
and
package Foo 0.42;
and
package Foo 0.42 { ... }
and not only do we look for the "package" keyword, but also for "class". π
in list context this method will return an arrayref to a list of structures:
- pkg β the name of the
"package"/"class". - version β the version for that
"package"/"class". (can be absent if$PERL_V_SHOW_ALLis true.) - ord β the ordinal number of occurrence in the file.
πΈ DESCRIPTION πΈ
so this module uses stolen code from Module::Info to find the location and version of the module(s) you asked about. it prints them and exit()s. that's it, that's the plot. π
it defines "import ()" and is based on an idea from Michael Schwern on the perl5-porters list. see the discussion:
https://www.nntp.perl.org/group/perl.perl5.porters/2002/01/msg51007.html
π§ V::get_version($pkg)
returns the version of the first available file for this package as found by following @INC.
Arguments
$pkgβ the name of the package for which one wants to know the version.
Response
this "V::get_version ()" returns the version of the file that was first found for this package by following @INC, or "undef" if no file was found. π«Ά
π SEE ALSO π
there are numerous modules on CPAN that (try to) extract the VERSION from modules. ExtUtils::MakeMaker maybe being th most important inspiration. Module::Info was used to copy code from.
π AUTHOR π
Abe Timmerman -- 2002 - 2024 (β 2024-08-15 π’)
H.Merijn Brand C<< <hmbrand@cpan.org> >> (2026 ...)
π COPYRIGHT AND LICENSE π
Copyright 2024-2026 H.Merijn Brand, All Rights Reserved. Copyright 2002-2024 Abe Timmerman, All Rights Reserved.
this library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. π
this program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
and that's a wrap, bestie π¦β¨ β this was V(3pm) from the perl v5.40.1 distribution, dated 2026-01-25. slay, go check some versions, ily π«Άπ
π¦ where this page comes from
- ubuntu resolute: libv-perl 0.23-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libv-perl 0.23-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms