Finding Installed Perl Modules

By | | Open Source

In working with numerous servers, some my own and many under client ownership, I bump into interesting issues to tackle (yep, this is obvious I know, we all do!). As most of us do now when stumped, a first resort is to Google the problem and see who has already resolved it.

Just a few weeks ago I was wrestling with a web-based Perl application problem for some advanced scripts that I had not authored and became convinced it was related to modules (does anyone else get flustered with obfuscated Perl error messages?!).

I happened to have a snippet of code for identifying all modules installed tucked away and was finally able to track down which module was not installed that resolved the issue.

Perhaps other will find some value in being able to generate lists of modules installed. A disclaimer on this code – I remember finding it through a Google search sometime back (at least a year ago) – but cannot track back down who posted it and where. So – for insuring proper credit is issued – I did not author this handy little piece.

perl -MFile::Find=find -MFile::Spec::Functions -lwe 'find { wanted => sub { print canonpath $_ if /\.pm\z/ }, no_chdir => 1 }, @INC'

Written By:

Blane Warrene

Blane is a writer and researcher focusing on Apple and Open Source technologies. Prior to this, he helped found a commercial software and consulting venture, and worked in the financial services sector as a director of technology and in varying technical roles. Blane maintains Open Sourcery: SitePoint's Open Source Blog.

Website
>> More Posts By Blane Warrene

 

{ 12 comments }

Raj Shivage February 7, 2008 at 12:29 am

there is easy way to find installed modules
Run this command
perl -MModule::Name -e l

Dinesh May 23, 2006 at 3:40 pm

Use this script to see the modules installed on your system OR type perldoc perllocal

#!/usr/bin/perl -w

use ExtUtils::Installed;
my $instmod = ExtUtils::Installed->new();
foreach my $module ($instmod->modules()) {
my $version = $instmod->version($module) || “Version Not Found”;
print “$module — $version\n”;
}

BUT is there a way in which i can find modules installed on a particular directory
example :- All modules installed under /home/username

vasundhar May 6, 2006 at 4:22 am

there was some problem in my previous post
I meant Perldoc MODULENAME

vasundhar May 6, 2006 at 4:21 am

what about perldoc

Simple and easy check if you have module installed,
Also its documentation

aperson March 22, 2006 at 1:12 am

For people like Fred.

Maybe you need to update your browser, it all works with a modern browser that handles CSS! Why not try Firefox?

bhbriggs November 24, 2004 at 12:37 pm

this (what perl mods are installed) was exactly what I was looking for. Thanks

Fred November 21, 2004 at 12:38 am

What a terrible site this is. I can’t scroll in the usual way and then they put this code in a non-standard text box where I can’t evn do a select all.

…stupid and useless.

I won’t be back to sitepoint.com and I’m sure these people will take down this comment and ignore it.

Mark Aufflick October 12, 2004 at 8:31 pm

If you have a particular module you want to find out about, I just do this:

perl -MMy::Module -e ‘print 1′

if the module doesn’t exist you will get an error (and @INC to boot) – if it does exist you will get a 1 printed out.

Real easy to remember too…

lawrephord2 October 8, 2004 at 4:41 pm

would it be an exercise in futility to write
cpm/86 in perl ? A NICE EMULATOR ALSO CPM/80
FOR THE Z80 ANTOPSYS LOOK FOR ANTIQUE OPERATING SYSTEMS IN MSN GROUPS

Anonymous September 27, 2004 at 1:48 am

whats wrong w print @INC ?

Sergey September 4, 2004 at 8:29 am

Blane, can you list some of these “obfuscated” error messages?

ultra September 2, 2004 at 11:59 am

My Windoze install wanted double quotes for this very helpful one-liner;

Here’s the modified code:

perl -MFile::Find=find -MFile::Spec::Functions -lwe “find { wanted => sub { print canonpath $_ if /\.pm\z/ }, no_chdir => 1 }, @INC”

Thanks!
U

Comments on this entry are closed.