perlisfun has asked for the wisdom of the Perl Monks concerning the following question:

Hi, These days, my boss, he like to learn perl, he used to be heavy shell programmer. He asked me how many perl modules are installed on our system. I just know where all the perl modules are installed and all *.pm files. But i really believe perl does have a command to show all the installed packages. If you got a clue, please drop a few lines. Really appreciate it. perlisfun
  • Comment on How to list all the installed perl modules

Replies are listed 'Best First'.
Re: How to list all the installed perl modules
by abstracts (Hermit) on Mar 17, 2002 at 02:38 UTC
    Hello

    If you look at the top of the page, there is a box called "Search", and that's for searching the site. If you type in that box "list all modules", and press enter, voilla, you'll see how many times this question came up, along with the answers, as well as pointers to FAQs and code.

    Hope this helps,,,

    Aziz,,,

Re: How to list all the installed perl modules
by gellyfish (Monsignor) on Mar 17, 2002 at 09:45 UTC
Re: How to list all the installed perl modules
by webadept (Pilgrim) on Mar 17, 2002 at 09:23 UTC
    If you are using ActivePerl use the ppm and type the query command with no options.. that will list all the modules installed with ppm

    Glenn H.
Re: How to list all the installed perl modules
by fuzzyping (Chaplain) on Mar 17, 2002 at 06:44 UTC
    This will list all modules available in your search path.
    perl -e 'while (<@INC>) { while (<$_/*.pm>) { print "$_\n"; } }'

    -fuzzyping

      uh, nope. your code doesn't account for the modules that live in the sub directories... For example, try finding File::Spec with your code.

      Probably best to stick to using File::Find to accomplish this job

      I think this code would not find Modules in Subdirectories, e.g. Net::Telnet, so I'd prefer using something like the following:
      use File::Find; # Module list foreach my $dir (@INC){ find sub { print "$File::Find::name\t" if /\.pm$/; }, $dir; }
      or shorter:
      use File::Find; find sub { print "$File::Find::name\t" if /\.pm$/; }, @INC;
        Yeah, I realized that shortly thereafter. I've been picking my brain trying to figure out a way to do this with native functions, but I can't scale the recursion. Anyone else have any ideas? I've tried checking the input for (-d) and pushing it back to @INC, but my "while" doesn't seem to honor this attempt...
        perl -e 'while (<@INC>) { while (<$_/**>) { if (-d) { push(@INC,$_) } +elsif (/\.pm/) { print "$_\n" } else { next } } }'

        -fuzzyping