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

I want to find out what perl modules are available for use in a code. How can I do that ? I tried perldoc perldoc, but it doesnt give the list of all modules installed. Is there a command or a way to find out what modules are installed ? thanks
  • Comment on how to find what modules are available for use ?

Replies are listed 'Best First'.
Re: how to find what modules are available for use ?
by moritz (Cardinal) on Oct 05, 2009 at 15:17 UTC

    See "perldoc perlfaq3", How do I find which modules are installed on my system?

    Apart from the methods mentioned there you can also use CPANPLUS to list all modules (though I forgot the exact mechanism).

    Update: This is the CPANPLUS solution I sometimes use; I have no idea if it's available from the command line interface too:

    use strict; use warnings; use CPANPLUS; my $c = CPANPLUS::Backend->new(); my %seen; for my $m ($c->installed()) { next if $seen{$m->package}++; print $m->package(), "\t\t", $m->version(), $/; }
    Perl 6 - links to (nearly) everything that is Perl 6.
      I didn't see it in perlfaq3, so I'll just mention that I use perldoc perllocal in combination with corelist. It's not foolproof—for example, it doesn't play well with Module::Build-based modules—but it gives a pretty good idea of what's on my system.
Re: how to find what modules are available for use ?
by toolic (Bishop) on Oct 05, 2009 at 15:22 UTC
Re: how to find what modules are available for use ?
by ikegami (Patriarch) on Oct 05, 2009 at 15:49 UTC

    what modules are available for use ?

    Most of these

    Also see this page for groupings of that list.

    Update: I forgot to mention that Module::CoreList can list the modules that come with various version of Perl

    (5.010001 is 5.10.1)
Re: how to find what modules are available for use ?
by planetscape (Chancellor) on Oct 05, 2009 at 18:42 UTC
Re: how to find what modules are available for use ?
by Khen1950fx (Canon) on Oct 05, 2009 at 17:48 UTC
    Another way:

    #!/sw/bin/perl use strict; use warnings; use ExtUtils::Installed; use Data::Dumper; my ($inst) = ExtUtils::Installed->new(); print Dumper my (@modules) = $inst->modules( "all" );
    Update: There's an even better way to do it with this script by toolic.
Re: how to find what modules are available for use ?
by jakobi (Pilgrim) on Oct 05, 2009 at 15:36 UTC

    There's also a wrong answer (Unix variant):

    locate perl | grep -i ModuleCategory/ModuleName, maybe with a grep for 'pm$' added. If necessary, replace locate ... with find /usr/*/perl* /opt/perl* /usr/*/*/perl*, but that's a bit slower.

    It misses some, it adds some, but if you rarely use the 'correct' methods (@INC as mentioned above or the FAQs), it's way faster to remember :). So don't forget about the lowtech approach.

Re: how to find what modules are available for use ?
by hippsta (Acolyte) on Oct 05, 2009 at 19:57 UTC
    IMO the most simple way is running:

    # instmodsh

    in as root in shell.

    :)
    Respectfully,

    Brother Hippsta