"gusmeister" <gu****************@sympatico.ca> wrote in message news:<F2********************@news20.bellglobal.com >...
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.)