.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "V 3pm" .TH V 3pm 2024-01-20 "perl v5.38.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME V \- Print version of the specified module(s). .SH SYNOPSIS .IX Header "SYNOPSIS" .Vb 1 \& $ perl \-MV=V .Ve .PP or if you want more than one .PP .Vb 1 \& $ perl \-MV=CPAN,V .Ve .PP Can now also be used as a light-weight module for getting versions of modules without loading them: .PP .Vb 2 \& require V; \& printf "%s has version \*(Aq%s\*(Aq\en", "V", V::get_version( "V" ); .Ve .PP Starting with version \fB0.17\fR, V will show all \f(CW\*(C`package\*(C'\fRs or \f(CW\*(C`class\*(C'\fRes in a file that have a version. If one wants to see all packages/classes from that file, set the environment variable \f(CW\*(C`PERL_V_SHOW_ALL\*(C'\fR to a \fItrue\fR value. .PP If you want all available files/versions from \f(CW@INC\fR: .PP .Vb 10 \& require V; \& my @all_V = V::Module::Info\->all_installed("V"); \& printf "%s:\en", $all_V[0]\->name; \& for my $file (@all_V) { \& my ($versions) = $file\->version; # Must be list context \& if (@$versions > 1) { \& printf "\et%s:\en", $file\->name; \& for my $ver (@versions) { \& print "\et %\-30s: %s\en", $ver\->{pkg}, $ver\->{version}; \& } \& } \& else { \& printf "\et%\-50s \- %s\en", $file\->file, $versions\->[0]{version}; \& } \& } .Ve .PP Each element in that array isa \f(CW\*(C`V::Module::Info\*(C'\fR object with 3 attributes and a method: .IP "\fIattribute\fR \fBname\fR" 4 .IX Item "attribute name" The package name. .IP "\fIattribute\fR \fBfile\fR" 4 .IX Item "attribute file" Full filename with directory. .IP "\fIattribute\fR \fBdir\fR" 4 .IX Item "attribute dir" The base directory (from \f(CW@INC\fR) where the package-file was found. .IP "\fImethod\fR \fBversion\fR" 4 .IX Item "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 \&\fB0.13_01\fR, all versions found are passed through the version module. .Sp As of version \fB0.16_03\fR we look for all types of version declaration: .Sp .Vb 2 \& package Foo; \& our $VERSION = 0.42; .Ve .Sp and .Sp .Vb 1 \& package Foo 0.42; .Ve .Sp and .Sp .Vb 1 \& package Foo 0.42 { ... } .Ve .Sp Not only do we look for the \f(CW\*(C`package\*(C'\fR keyword, but also for \f(CW\*(C`class\*(C'\fR. In list context this method will return an arrayref to a list of structures: .RS 4 .IP \fIpkg\fR 8 .IX Item "pkg" The name of the \f(CW\*(C`package\*(C'\fR/\f(CW\*(C`class\*(C'\fR. .IP \fIversion\fR 8 .IX Item "version" The version for that \f(CW\*(C`package\*(C'\fR/\f(CW\*(C`class\*(C'\fR. (Can be absent if \f(CW$PERL_V_SHOW_ALL\fR is true.) .IP \fIord\fR 8 .IX Item "ord" The ordinal number of occurrence in the file. .RE .RS 4 .RE .SH DESCRIPTION .IX Header "DESCRIPTION" This module uses stolen code from Module::Info to find the location and version of the specified module(s). It prints them and \fBexit()\fRs. .PP It defines \f(CWimport()\fR and is based on an idea from Michael Schwern on the perl5\-porters list. See the discussion: .PP .Vb 1 \& https://www.nntp.perl.org/group/perl.perl5.porters/2002/01/msg51007.html .Ve .SS V::get_version($pkg) .IX Subsection "V::get_version($pkg)" Returns the version of the first available file for this package as found by following \f(CW@INC\fR. .PP \fIArguments\fR .IX Subsection "Arguments" .ie n .IP "1. $pkg" 4 .el .IP "1. \f(CW$pkg\fR" 4 .IX Item "1. $pkg" The name of the package for which one wants to know the version. .PP \fIResponse\fR .IX Subsection "Response" .PP This \f(CWV::get_version()\fR returns the version of the file that was first found for this package by following \f(CW@INC\fR or \f(CW\*(C`undef\*(C'\fR if no file was found. .SH AUTHOR .IX Header "AUTHOR" Abe Timmerman \f(CW\*(C`\*(C'\fR. .SH "COPYRIGHT & LICENSE" .IX Header "COPYRIGHT & LICENSE" Copyright 2002\-2006 Abe Timmerman, All Rights Reserved. .PP This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. .PP 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.