/usr/share/perl5/V.pm is in libv-perl 0.13-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 | package V;
use strict;
# $Id: V.pm 1126 2007-11-07 00:10:02Z abeltje $
use vars qw( $VERSION $NO_EXIT );
$VERSION = '0.13';
$NO_EXIT ||= 0; # prevent import() from exit()ing and fall of the edge
=head1 NAME
V - Print version of the specified module(s).
=head1 SYNOPSIS
$ perl -MV=V
or if you want more than one
$ perl -MV=CPAN,V
Can now also be used as a light-weight module for getting versions of
modules without loading them:
BEGIN { $V::NO_EXIT = 1 }
require V;
printf "%s has version '%s'\n", "V", V::get_version( "V" );
=head1 DESCRIPTION
This module uses stolen code from L<Module::Info> to find the location
and version of the specified module(s). It prints them and exit()s.
It defines C<import()> and is based on an idea from Michael Schwern
on the perl5-porters list. See the discussion:
http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2002-01/msg00760.html
=head1 AUTHOR
Abe Timmerman C<< <abeltje@cpan.org> >>.
=head1 COPYRIGHT & LICENSE
Copyright 2002-2006 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.
=cut
sub report_pkg($@) {
my $pkg = shift;
print "$pkg\n";
@_ or print "\tNot found\n";
for my $module ( @_ ) {
printf "\t%s: %s\n", $module->file, $module->version || '?';
}
}
sub import {
shift;
@_ or push @_, 'V';
for my $pkg ( @_ ) {
my @modules = V::Module::Info->all_installed( $pkg );
report_pkg $pkg, @modules;
}
exit() unless $NO_EXIT;
}
sub get_version {
my( $pkg ) = @_;
my( $first ) = V::Module::Info->all_installed( $pkg );
return $first ? $first->version : undef;
}
caller or V->import( @ARGV );
1;
# Okay I did the AUTOLOAD() bit, but this is a Copy 'n Paste job.
# Thank you Michael Schwern for Module::Info! This one is mostly that!
package V::Module::Info;
require File::Spec;
sub new_from_file {
my($proto, $file) = @_;
my($class) = ref $proto || $proto;
return unless -r $file;
my $self = {};
$self->{file} = File::Spec->rel2abs($file);
$self->{dir} = '';
$self->{name} = '';
return bless $self, $class;
}
sub all_installed {
my($proto, $name, @inc) = @_;
my($class) = ref $proto || $proto;
@inc = @INC unless @inc;
my $file = File::Spec->catfile(split m/::/, $name) . '.pm';
my @modules = ();
foreach my $dir (@inc) {
# Skip the new code ref in @INC feature.
next if ref $dir;
my $filename = File::Spec->catfile($dir, $file);
if( -r $filename ) {
my $module = $class->new_from_file($filename);
$module->{dir} = File::Spec->rel2abs($dir);
$module->{name} = $name;
push @modules, $module;
}
}
return @modules;
}
# Thieved from ExtUtils::MM_Unix 1.12603
sub version {
my($self) = shift;
my $parsefile = $self->file;
local *MOD;
open(MOD, $parsefile) or die $!;
my $inpod = 0;
my $result;
local $_;
while (<MOD>) {
$inpod = /^=(?!cut)/ ? 1 : /^=cut/ ? 0 : $inpod;
next if $inpod || /^\s*#/;
chomp;
next unless m/([\$*])(([\w\:\']*)\bVERSION)\b.*\=/;
{ local($1, $2); ($_ = $_) = m/(.*)/; } # untaint
my $eval = qq{
package V::Module::Info::_version;
no strict;
local $1$2;
\$$2=undef; do {
$_
}; \$$2
};
local $^W = 0;
$result = eval($eval);
warn "Could not eval '$eval' in $parsefile: $@" if $@;
$result = "undef" unless defined $result;
last;
}
close MOD;
return $result;
}
sub accessor {
my $self = shift;
my $field = shift;
$self->{ $field } = $_[0] if @_;
return $self->{ $field };
}
sub AUTOLOAD {
my( $self ) = @_;
use vars qw( $AUTOLOAD );
my( $method ) = $AUTOLOAD =~ m|.+::(.+)$|;
if ( exists $self->{ $method } ) {
splice @_, 1, 0, $method;
goto &accessor;
}
}
|