Reputation: 1293
I need to find the location of my perl library/libraries how can I do this? Something similar to what this gives you for python...
python -c "import sys; print sys.path"
Thanks
Upvotes: 0
Views: 623
Reputation:
List all places where modules will be looked for: perl -E 'say for @INC'
List all the actual files modules have been loaded from: perl -E 'say for keys %INC'
Upvotes: 2
Reputation: 13792
print the contents of the @INC
variable:
perl -e 'print "@INC\n";'
@INC
contains all the paths that Perl will search to find a module.
Upvotes: 1
Reputation: 35198
The physical location of loaded modules are in the %INC
hash:
%INC
The hash
%INC
contains entries for each filename included via thedo
,require
, oruse
operators. The key is the filename you specified (with module names converted to pathnames), and the value is the location of the file found. Therequire
operator uses this hash to determine whether a particular file has already been included.If the file was loaded via a hook (e.g. a subroutine reference, see require for a description of these hooks), this hook is by default inserted into
%INC
in place of a filename. Note, however, that the hook may have set the%INC
entry by itself to provide some more specific info.
Usage demonstrated for a random module on my system:
$ perl -MFile::Slurp -e 'print $INC{"File/Slurp.pm"}'
/Users/miller/perl5/perlbrew/perls/perl-5.20.0/lib/site_perl/5.20.0/File/Slurp.pm
Upvotes: 2