How can I find out where a Perl module is installed?

Viewed 87828

How do get the path of a installed Perl module by name, e.g. Time::HiRes?

I want this just because I have to run my perl script on different nodes of a SGE Grid Engine system. Sometimes, even run as other username.

I can use CPAN.pm to install packages for myself, but it is not so easy to install for other users without chmod 666 on folders.

10 Answers

I like to use the V module.

Just install it from CPAN or by installing the package libv-perl on Debian or Ubuntu.

Then use it like this:

$ perl -MV=DBI
DBI
    /Users/michiel/.plenv/versions/5.24.0/lib/perl5/site_perl/5.24.0/darwin-2level/DBI.pm: 1.636

Other output example:

$ perl -MV=Time::HiRes
Time::HiRes
    /usr/lib/perl/5.18/Time/HiRes.pm: 1.9725

Perldoc -l works for me

perldoc -l "File::Find"
/opt/perl_32/lib/5.8.8/File/Find.pm

To expand on @Ivan's answer that allows this to be run without installing additional software the following will use Perl's debugger to find a specific module (or modules):

perl -de 'use <Module Name>;'

For Example:

perl -de 'use DBD::Oracle;'

Output:

Loading DB routines from perl5db.pl version 1.37
Editor support available.

Enter h or 'h h' for help, or 'man perldebug' for more help.

DBD::Oracle::CODE(0x27f81d8)(/usr/local/lib64/perl5/DBD/Oracle.pm:113):
113:            $ENV{PERL_BADFREE} = 0;
  DB<1> q

In OSX you can use:

perl -e 'print join("\n",@INC)'

The result should be the location of your lib.

Then add this code in your Perl code:

use lib '/your/folder/location/to/lib';
Related