1V(3) User Contributed Perl Documentation V(3)
2
3
4
6 V - Print version of the specified module(s).
7
9 $ perl -MV=V
10
11 or if you want more than one
12
13 $ perl -MV=CPAN,V
14
15 Can now also be used as a light-weight module for getting versions of
16 modules without loading them:
17
18 require V;
19 printf "%s has version '%s'\n", "V", V::get_version( "V" );
20
21 Starting with version 0.17, V will show all "package"s or "class"es in
22 a file.
23
24 If you want all available files/versions from @INC:
25
26 require V;
27 my @all_V = V::Module::Info->all_installed("V");
28 printf "%s:\n", $all_V[0]->name;
29 for my $file (@all_V) {
30 my ($versions) = $file->version; # Must be list context
31 if (@$versions > 1) {
32 printf "\t%s:\n", $file->name;
33 for my $ver (@versions) {
34 print "\t %-30s: %s\n", $ver->{pkg}, $ver->{version};
35 }
36 }
37 else {
38 printf "\t%-50s - %s\n", $file->file, $versions->[0]{version};
39 }
40 }
41
42 Each element in that array isa "V::Module::Info" object with 3
43 attributes and a method:
44
45 attribute name
46 The package name.
47
48 attribute file
49 Full filename with directory.
50
51 attribute dir
52 The base directory (from @INC) where the package-file was found.
53
54 method version
55 This method will look through the file to see if it can find a
56 version assignment in the file and uses that to determine the
57 version. As of version 0.13_01, all versions found are passed
58 through the version module.
59
60 As of version 0.16_03 we look for all types of version declaration:
61
62 package Foo;
63 our $VERSION = 0.42;
64
65 and
66
67 package Foo 0.42;
68
69 and
70
71 package Foo 0.42 { ... }
72
73 Not only do we look for the "package" keyword, but also for
74 "class". In list context this method will return an arrayref to a
75 list of structures:
76
77 pkg The name of the "package"/"class".
78
79 version The version for that "package"/"class".
80
82 This module uses stolen code from Module::Info to find the location and
83 version of the specified module(s). It prints them and exit()s.
84
85 It defines import() and is based on an idea from Michael Schwern on the
86 perl5-porters list. See the discussion:
87
88 https://www.nntp.perl.org/group/perl.perl5.porters/2002/01/msg51007.html
89
90 V::get_version($pkg)
91 Returns the version of the first available file for this package as
92 found by following @INC.
93
94 Arguments
95
96 1. $pkg
97 The name of the package for which one wants to know the version.
98
99 Response
100
101 This V::get_version() returns the version of the file that was first
102 found for this package by following @INC or "undef" if no file was
103 found.
104
106 Abe Timmerman "<abeltje@cpan.org>".
107
109 Copyright 2002-2006 Abe Timmerman, All Rights Reserved.
110
111 This library is free software; you can redistribute it and/or modify it
112 under the same terms as Perl itself.
113
114 This program is distributed in the hope that it will be useful, but
115 WITHOUT ANY WARRANTY; without even the implied warranty of
116 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
117
118
119
120perl v5.36.1 2023-11-11 V(3)