http://www.perlmonks.org?node_id=1074097


in reply to How to find path of Perl modules used in a code

If Perl modules are used as above in Perl code, where and how do I find path for these modules ?

The perl search path is (mostly) not in the environment, it is built into perl. The only search path alternative in the environment is the variable PERL5LIB, whose content will be prepended to the search path list, which is in the perl special variable @INC.

If my PERL5LIB contains /home/shmem/perl/lib then:

qwurx [shmem] ~ > perl -le 'print $INC[0]' /home/shmem/comp/perl/lib

To get the path of a loaded module, convert all double colons to slashes and append ".pm" (e.g. TeamSite::CGI_lite becomes TeamSite/CGI_lite.pm), and lookup that key in the hash %INC.

Examples (see perlrun for the command line switch -M):

qwurx [shmem] ~ > perl -MIO::Select -le 'print $INC{q(IO/Select.pm)}' /usr/lib/perl/5.14/IO/Select.pm qwurx [shmem] ~ > perl -My -le 'my $m = q(y.pm);print $INC{$m}' /home/shmem/comp/perl/lib/y.pm

Note that the above examples are for Linux/UNIX/cygwin. Use double quotes in cmd.exe on Windows.

update: added @INC code example, y.pm example

perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'