Are you wondering where the heck does some arcane module come from? Wonder no more, perlwhich comes to the rescue:

use strict;
use File::Spec;

my $module = shift @ARGV;
my $pm=$module.'.pm';
my @path = split(/::/,$pm);
my $found = 0;
foreach my $dir (@INC) {
        my $file = File::Spec->catfile($dir,@path);
        if(-f $file) {
                print $file,"\n";

Next time you need to know some module’s path just run it like this:

$ perlwhich Data::Dumper

If a module resides in multiple locations under @INC, perlwhich will let you know as well:

$ perlwhich Salesforce

One thought on “perlwhich”

  1. “perldoc -l Module::Name” does this job almost as well, unless there’s no pod, or the pod comes from a separate file.
    “perldoc -m Module::Name” dumps that file to stdout – great for grepping.

Comments are closed.