This is part of The Pile, a partial archive of some open source mailing lists and newsgroups.
From: AlV <skweek@no.spam>
Subject: Re: How to check perl modules
Newsgroups: comp.lang.perl.modules
Date: Mon, 06 Oct 2003 17:14:29 +0200
Organization: Wanadoo, l'internet avec France Telecom
jjliu wrote:
> How can I check perl modules to see if they are already install in my perl,
> such as the following:
> LWP::Simple
> HTML::Tokeparser
> HTML::LinkExtractor
> ...
This should help...
(found quite a long time ago in a newsgroup: thanks to the
original author :o)
: # -*-perl-*-
eval 'exec perl -w -S $0 ${1+"$@"}'
if 0;
use warnings;
use strict;
use ExtUtils::Installed;
# Find all the installed modules
print("Finding all installed Perl modules...\n");
my $installed = ExtUtils::Installed->new();
my $max_length = 0;
# Let's find the longest name
foreach my $module (grep(!/^Perl$/, $installed->modules()))
{
(length ($module) > $max_length) and $max_length = length ($module);
}
# A nice way to print the results
my $format = " %-".$max_length."s Version %s\n";
# We display all the modules along with their version
foreach my $module (grep(!/^Perl$/, $installed->modules()))
{
my $version = $installed->version($module) || "???";
printf($format, $module, $version);
}
===
From: pjacklam@online.no (Peter J. Acklam)
Subject: Re: How to check perl modules
Newsgroups: comp.lang.perl.modules
Date: Mon, 06 Oct 2003 18:17:59 +0200
Organization: Private
"jjliu" <jjliu@earthlink.net> wrote:
> How can I check perl modules to see if they are already install in my perl,
> such as the following:
>
> LWP::Simple
> HTML::Tokeparser
> HTML::LinkExtractor
> ...
Just see if you can find the corresponding .pm file along the @INC path:
#!/usr/bin/env perl
use strict;
use warnings;
use File::Spec;
for (@ARGV) {
my $file = File::Spec->join(split /::/) . '.pm';
my $seen = grep { -f File::Spec->join($_, $file) } @INC;
print $_, ': ', $seen ? 'YES' : 'NO', "\n";
}
===
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: How to check perl modules
Keywords: germicide, haunt, protestant, trafficked
Newsgroups: comp.lang.perl.modules
Date: Thu, 9 Oct 2003 03:55:57 +0000 (UTC)
Organization: Plover Systems Co.
In article <oCegb.138$Eo2.39@newsread2.news.atl.earthlink.net>,
jjliu <jjliu@earthlink.net> wrote:
>How can I check perl modules to see if they are already install in my perl,
>such as the following:
>
>LWP::Simple
>HTML::Tokeparser
>HTML::LinkExtractor
>...
perl -MLWP::Simple -e1
If the command says nothing, then LWP::Simple is installed.
If it prints an error message, LWP::Simple is not installed.
plover% perl -MLWP::Simple -e1
plover% perl -MDoes::Not::Exist -e1
Can't locate Does/Not/Exist.pm in @INC (@INC contains: ...).
BEGIN failed--compilation aborted.
===