Listing installed perl modules

G

gusmeister

Is there a command that allows me to list all the installed Perl modules on
my machine?
 
J

Joe Smith

gusmeister said:
Is there a command that allows me to list all the installed Perl modules on
my machine?

If you've set up CPAN, use
perl -MCPAN -e autobundle
to get a list of the modules and version numbers.
-Joe
 
W

Will Stranathan

gusmeister said:
Is there a command that allows me to list all the installed Perl modules on
my machine?

If you're using ActivePerl, you can also do:
ppm query *

This will tell you all the PPM PACKAGES that are installed, but not
necessarily all the MODULES that are installed.

Alternatively, you could do something like:

use strict;
use warnings;

my %libs;

sub workdir {
my ($dir,$prefix) = (@_,'');
$prefix and $prefix .= '::';
opendir DIR, $dir;
for my $f (grep {!/^\.\.?$/} readdir(DIR)) {
if (-f "$dir/$f" && $f =~ /^(.*)\.pm$/i) {
$libs{"${prefix}$1"} = '';
} elsif (-d "$dir/$f") {
&workdir("$dir/$f", "$prefix$f");
}
}
}

my @libs;
for my $inc (@INC) {
workdir($inc);
}
for (sort keys %libs) {
print "$_\n";
}

This is NOT complete, though. To TRULY work, you really need to check
if the package specified in the .pm file matches the package you're
purporting it to be in. (For example, if you've got a bunch of .pm
files really deep below ., but they're not in a package, they'd still
show up in a package that looks like the directory structure.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top