Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

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

by shmem (Canon)
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'


Comment on Re: How to find path of Perl modules used in a code
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1074097]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (10)
As of 2014-07-31 12:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (248 votes), past polls