perlwh.pl - a 'which' for Perl Modules

Download this program

SYNOPSIS

        perlwh.pl Long              # Looks for .*Long.*\.pm
        perlwh.pl -igno long        # Looks for case insensitive .*long.*\.pm
        perlwh.pl 'a.m'             # Looks for "a + one char + m"
        perlwh.pl -exactly DB       # Looks for DB.pm
        perlwh.pl -startswith DB    # Looks for /^DM.+\.pm/
        perlwh.pl -endswith DB      # Looks for /DB\.pm$/
        perlwh.pl .                 # Show all installed modules


DESCRIPTION

This program can be used to show Perl modules available to your Perl installation. Sometimes you remember PART of the name of a module. You can use this program to show you all modules on your @INC path with the module name partially specified. This program was inspired by wh.pl which searches for executables on your PATH.

This program should work on either Unix or DOS systems where Perl is installed.

Use Perl regular expressions with a module name to find modules on @INC. Don't forget, you may need to escape special characters so the shell will not expand them. E.g. perlwh.pl 'l[fc]s'

In addition to your normal @INC and $PERL5LIB path, the program will search additional paths you added to @add2inc at the top of the program.

The default action is to show any module whose name contains the string you provide. For instance, 'perlwh.pl DB' would find all modules which have the characters 'DB' in the name (a surprisingly long list typically). This would include 'DBM.pm', 'TestPerlDB.pm', among others.

On well-behaved systems, the following Perl program will show all the modules you have installed (from the Perl FAQ):

  use ExtUtils::Installed;
  my $instmod = ExtUtils::Installed->new();
  foreach my $module ($instmod->modules()) {
  my $version = $instmod->version($module) || "???";
    print "$module -- $version\n";
  }
  exit;

The Perl module used here relies on .packlist files which SHOULD have been installed with each module. Unfortunately, we all to often live in a world of imperfect systems. The Debian Linux distribution, for instance, does NOT distribute the .packlist files.

This script applies a much more heuristic approach to finding modules. It should find ALL your modules, but it may well find a few MORE than really exist (or may find some sort of duplicate).

This program shows the modules installed for the Perl interpreter that is executing this script. If you have more than one perl binary, you can check each out by specifying the path to Perl explicitly, e.g.

  /usr/local/bin/perl terrys/pgms/perlwh.pl .


OPTIONS

-archname NAME
Specifies the archname for this version of Perl. I cannot imagine a reason you would ever specify this. You should be able to see the archname for your Perl with the command: perl -V | grep archname

-dirdepth N
Specifies how many levels the script will look for directories in the @INC trees. Use this to avoid possible loops because of incorrect symlinks. This defaults to 3.

-endswith
Indicates the the module name 'ends with' the name provided. Specifying '-endswith DB' would find 'DB.pm', but not 'DBI.pm'.

-exactly
Do not use any regular expression matching when looking for the module.

-help
Shows you this help file.

-ignorecase
Indicates the the module name comparison should be case insensitive. The default to match the case of the string you provide.

-startswith
Indicates the the module name 'starts with' the name provided. Specifying '-startswith DB' would find 'DBM.pm', but not 'TestPerlDB.pm'

-verose N
Provides increasingly more additional information. N defaults to 0 (minimal information).


PARAMETERS

str1 [str2 ... strN]
This is the string used to find modules in your @INC search path. You may specify more than one string (module name) to search for.


EXIT

If no fatal errors are detected, the program exits with a return code of 0.


AUTHOR

Written by Terry Gliedt <tpg@hps.com> in 2004-2005 This is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; See http://www.gnu.org/copyleft/gpl.html