Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: perl modules

by ELISHEVA (Prior)
on Mar 05, 2009 at 22:06 UTC ( [id://748688]=note: print w/replies, xml ) Need Help??


in reply to perl modules

instmodsh only shows your locally installed modules - that is, the things you installed using CPAN. It will not list core modules or things that automatically come with your Perl distribution (for example, the debconf modules that are installed on all Debian systems).

To check if a particular module is installed, you can use the perldoc command:

  • perldoc -l Foo::Bar prints out the full path to the module
  • perldoc -m Foo::Bar displays the contents of the module file

If you want to see all the modules available given your current search path, try the following short script. This script works on both Win and *nix:

use strict; use warnings; use File::Find; my @aModules; foreach my $sDir (@INC) { my $crFind = sub { my $sModule = substr($File::Find::name, length($sDir)+1); push(@aModules, $sModule) if (($sModule =~ s/\.pm$//) || ($sModule =~ /\.pl$/)); }; find($crFind, ("$sDir/")) if -d $sDir; }; print '' . join("\n", sort @aModules) . "\n";

Note: the main difference between oko1's solution and mine is that oko1 provides support for filtering your module list with regexes but does not sort modules or list .pl files. The solution above does not support regex selection but does sort modules and list .pl files.

Best, beth

Update: fixed cut&paste error in script.

Update: eliminated warnings for missing @INC dirs; insured directory name is terminated with "/" so that File::Find doesn't think directory names with dots (e.g. /usr/share/perl/5.8) are files and skip them -silly File::Find) - with thanks to oko1 whose code sample below alerted me to these problems. Also added note comparing oko1 solution below and this solution.

Replies are listed 'Best First'.
Re^2: perl modules
by Anonymous Monk on Mar 06, 2009 at 08:15 UTC
    it will not list core modules or ...
    'm Perl'

      The behavior of m Perl is installation dependent. On Debian, for example, anything installed by apt-get (i.e. core and vendor modules) is managed by dpkg, rather than ExtUtils, so m Perl followed by d all or f all lists nada - see here

      Best, beth

        so they're well known bugs of apt-get/dpkg

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://748688]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (3)
As of 2024-04-25 20:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found