Listing installed perl modules

Discussion in 'Perl' started by gusmeister, Mar 2, 2004.

  1. gusmeister

    gusmeister Guest

    Is there a command that allows me to list all the installed Perl modules on
    my machine?
     
    gusmeister, Mar 2, 2004
    #1
    1. Advertising

  2. Gunnar Hjalmarsson, Mar 2, 2004
    #2
    1. Advertising

  3. gusmeister

    Joe Smith Guest

    gusmeister wrote:

    > Is there a command that allows me to list all the installed Perl modules on
    > my machine?


    If you've set up CPAN, use
    perl -MCPAN -e autobundle
    to get a list of the modules and version numbers.
    -Joe
     
    Joe Smith, Mar 3, 2004
    #3
  4. "gusmeister" <> wrote in message news:<F281c.12324$>...
    > 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.)
     
    Will Stranathan, Mar 3, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    2
    Views:
    494
    Joe Smith
    May 17, 2004
  2. Shilo Ayalon

    Listing installed gems

    Shilo Ayalon, Jan 25, 2009, in forum: Ruby
    Replies:
    7
    Views:
    144
    Rob Biedenharn
    Jan 26, 2009
  3. Yohan N Leder
    Replies:
    2
    Views:
    116
    Yohan N Leder
    Nov 8, 2006
  4. mike

    Perl modules installed

    mike, Nov 10, 2006, in forum: Perl Misc
    Replies:
    7
    Views:
    109
    brian d foy
    Nov 11, 2006
  5. Julien Phalip

    Listing modules from all installed packages

    Julien Phalip, Jun 9, 2013, in forum: Python
    Replies:
    5
    Views:
    154
    Julien Phalip
    Jun 14, 2013
Loading...

Share This Page