Skip to content →

List the perl modules installed on your box

Automatically inserted editorial note: this post was written 13 years ago, it may no longer represent my own views. Or just be a crazy post from my youth!

I’m not a hard-core Perl monger, but I recently needed to find out a list of the perl modules (and their version numbers) installed on a box.

I found the following script very useful:

#!/usr/local/bin/perl

use ExtUtils::Installed;
my $instmod = ExtUtils::Installed->new();
foreach my $module ($instmod->modules()) {
my $version = $instmod->version($module) || "???";
print "$module -- $version\n";
}

You can run the above from the command line as follows:

$ perl -e 'use strict; use CGI qw(:standard); use XML::RSS; use ExtUtils::Installed; my $installed = ExtUtils::Installed->new(); my $machine_name = `uname -n`; my $rss = new XML::RSS(version => '2.0'); $rss -> channel(title => "Perl Modules on $machine_name"); $rss -> channel(link => "http://www.benhammersley.com/tools/");foreach my $module ($installed->modules()) {my $version = $installed->version($module) || "???";$rss -> add_item ( title => "$module $version",description => "$module $version",link => "http://search.cpan.org/search%3fmodule=$module",); }print header('application/rss+xml'); print $rss->as_string;'

Finally, if you need to monitor any changes to the PM’s installed, Ben “man in a dress” Hammersley has written a nice little RSS outputter.

Published in Tools Uncategorized

2 Comments

  1. Matt McMillan Matt McMillan

    This method only works for perl modules that have .packlist files installed with them. I noticed that several modules that I know are installed did not show up with this command. I found a perl script called perlwh.pl here: http://www.hps.com/~tpg/toolbox/perlwh.php . It seems to get around the problem of missing .packlist files.

  2. Scott_CN Scott_CN

    use this command to check one module is installed or not:
    perl -e ‘use File::Compare; print “ok\n”‘

Comments are closed.