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

Re: How to find path of Perl modules used in a code

by shmem (Chancellor)
on Feb 09, 2014 at 08:59 UTC ( #1074097=note: print w/replies, xml ) Need Help??

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/, 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/}' /usr/lib/perl/5.14/IO/ qwurx [shmem] ~ > perl -My -le 'my $m = q(;print $INC{$m}' /home/shmem/comp/perl/lib/

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

update: added @INC code example, example

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

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1074097]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (6)
As of 2017-07-22 18:19 GMT
Find Nodes?
    Voting Booth?
    I came, I saw, I ...

    Results (340 votes). Check out past polls.