[Columbus-pm] which lib
Smith,Devon
smithde at oclc.org
Wed Apr 28 08:16:30 PDT 2010
Long time ago I wrote a script to tell me if a module was installed and
the version. Just modified it to tell me where as well.
/dev
--
Devon Smith
Consulting Software Engineer
OCLC Research
http://www.oclc.org/research/people/smith.htm
#!/usr/bin/perl -w
#$# created: 2005-05-11
#$# creator: Devon Smith
#$# description: Determine if/version/where modules are installed on the
system.
my @modules = qw (
Config::General
Date::Format
HTML::Template
JSON
Storable
Template
YAML
);
my $padding = 0;
map { $padding = length $_ if length $_ > $padding } @modules;
$padding += 5;
for ( @ARGV ) {
if ( -d $_ ) { # if a parameter is a directory, add it to @INC
eval "use lib '$_';";
}
else { # if it's not a directory, assume it's a module name
push @modules, $_;
}
}
for my $t (sort @modules) {
(my $path = $t) =~ s{::}{/}g;
$path .= '.pm';
# for each module, 'use' the module to check for its existence
# on the system, and get the version of the module, if present.
my $version;
eval "use $t; \$version = \$${t}::VERSION || '?';";
print $@ ? "no ... $t" : "ok ... $t/$version", ' ' x ($padding -
length $t), $INC{$path} ? " >> $INC{$path}" : '', "\n";
}
# vim: ts=4
-----Original Message-----
From: columbus-pm-bounces+smithde=oclc.org at pm.org
[mailto:columbus-pm-bounces+smithde=oclc.org at pm.org] On Behalf Of
Terrence Brannon
Sent: Wednesday, April 28, 2010 10:33 AM
To: Jonathan Hogue
Cc: columbus-pm
Subject: Re: [Columbus-pm] which lib
perl -MData::Dumper -MTest::More -e 'print Dumper \%INC'
you will see $INC{Test::More} pointing to it's location
regards from Boca Raton, FL! perhaps on my way to Memphis, TN!
-- Terrence
On Wed, Apr 28, 2010 at 10:15 AM, Jonathan Hogue <jon at hogue.org> wrote:
> Is there a way to effectively do a unix "which" on a perl library.
>
> like
>> which Test::More
> /usr/local/perl5/lib/Test/More.pm
>
> That would be cool.
More information about the Columbus-pm
mailing list