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

Hi, can someone explain to me how i can see a list of perl modules currently installed on a Unix or Linux environment? thanks

Replies are listed 'Best First'.
Re: perl modules
by {NULE} (Hermit) on Nov 14, 2001 at 09:09 UTC
    Hi,

    On my system (Linux)
    perldoc perllocal
    produces a list of modules I have installed using the CPAN shell. (perl -MCPAN -e shell). It does not report on modules that are part of the core distribution (like CGI.pm). To see more than that, try what our fellow monks have suggested before me.

    Update: Good call, Sweeper, I do that sometimes as well (like my work machine) - glad you mentioned it.

    {NULE}
    --
    http://www.nule.org

      I don't use CPAN.pm, I use the usual four incantations:
      perl Makefile.PL make make test make install
      and at the time of make install, the perllocal file is updated.

      So, perldoc perllocal works for me too.

Re: perl modules
by toma (Vicar) on Nov 14, 2001 at 08:59 UTC
    If you run perl -V you will see a bunch of output that describes your installation of perl. At the bottom is the array @INC which has the directories that include perl modules. You could write a perl program using File::Find to find the modules, or you could cd to these directories one at a time and execute
    find . -name '*.pm'
    and see lots of modules.

    It should work perfectly the first time! - toma

Re: perl modules
by Anonymous Monk on Nov 14, 2001 at 09:25 UTC
Re: perl modules
by Kanji (Parson) on Nov 14, 2001 at 09:21 UTC

    For a more automated approach to what ehdonhon and toma refer, see PerlDiver (sample output).

    Update: I've never used PerlDiver myself, but after reading mattr and jcwren comments, I took at look at it's source and have to agree: PerlDiver is pretty grotty. :(

        --k.


      It's also complete crap. No -w, no strict. All sorts of little 'tricks' to see if someone scammed their code. I rewrote it.

      --Chris

      e-mail jcwren

      I liked how PerlDiver looked until I downloaded it and realized that even if you put it on your own site it puts a banner with hit tracking in the background from the authors. And they "obfuscate" the cgi by removing line feeds, at least that's how it looked in my editor.

      The two versions of CPAN commands posted above are superior.

      Move SIG!

Re: perl modules
by ehdonhon (Curate) on Nov 14, 2001 at 08:56 UTC

    You can check each of your directories in @INC and see which of them have a .packlist file. That will tell you what Perl modules are installed, among other things. Though it probably more pratical on most systems to ask "Is module x installed" than to ask "what modules are installed".

Re: perl modules
by sm3g (Hermit) on Nov 14, 2001 at 23:33 UTC
    Tom Phoenix (one of the authors of the Llama book along with our own merlyn) has a program called Inside available here that does this.
    Here is a blurb from the readme:
    This program will try to report which Perl modules are available on your machine, along with some other useful information. Although it's especially made to be helpful to CGI programmers, it may be of use to other Perl users as well. Note that I've done more than a few weird things in this code in order to make it work in some odd surroundings. The right thing to do in general is to fix the broken environments, rather than to work around them. But since the purpose of this program is to diagnose some of those broken environments, I'm breaking the rules. In short: Don't Do As This Code Does! Use the accepted techniques, instead.
    I found it useful and pretty easy to run and will give you far more information than you (or at least I) need.

    requisite obfuscation sig below:
    perl -e 's;;uoli;;$a=length;y;g-w;e-u;;;$a--;s;j;$a;;print"$_\n";'
Re: perl modules
by Rich36 (Chaplain) on Nov 14, 2001 at 19:53 UTC
    Of you can try this script I wrote - findINC. Given a module name or fragment of a module name, it will recurse the @INC and find if it is installed.
    Rich36
    There's more than one way to screw it up...

      Why not just do perl -MModuleName?

      If that works, the module is installed and in the normal @INC locations. To conditionally do things based on whether or module is available within a real script, just put an eval block around require.