Ben Metcalfe

List the perl modules installed on your box

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.