Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

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/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'

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1074097]
help
Chatterbox?
[LanX]: *his
[holli]: And this guy was also Anti-Vaxx and I just snapped. I shoed him all over the yard
[james28909]: biting between the legs? now thats my kind of religion.
[holli]: and back into the building, saw him later peeking out of the window looking scared. It was hilarious.
[LanX]: Let's get physical...
[james28909]: wish i could stay and chat. i have an unsuspecting client to give an estimate to. muhhahaha

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (16)
As of 2017-12-13 18:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (373 votes). Check out past polls.

    Notices?