Blog Post RSS ?

Blogs » Open Source » Finding Installed Perl Modules
 

Finding Installed Perl Modules

by Blane Warrene

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'

This post has 12 responses so far

  1. 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

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

     
  3. whats wrong w print @INC ?

     
  4. 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

     
  5. 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…

     
  6. 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.

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

     
  8. 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?

     
  9. what about perldoc

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

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

     
  11. 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

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

     

Sponsored Links

Leave a response

You are not logged in, log in with your SitePoint Forum username and password.

-OR- Post Anonymously

* Make sure any code samples are escaped (i.e. ‘<b>’ becomes ‘&lt;b&gt;’).

If not logged in, your comments will be placed in a moderation queue. This means your comment may not appear until one of our moderators approves it.

SitePoint Marketplace

Buy and sell Websites, templates, domain names, hosting, graphics and more.