Thursday, April 8, 2010

Finding the Location of Perl Modules

There are (at least) two simple ways of finding the location on the file system of a perl module. The first is to use the perldoc command.
$ perldoc -l CPAN
/usr/lib/perl5/5.8.5/CPAN.pm
$ perldoc -l Pod::Perldoc
No documentation found for "Pod::Perldoc".
The second way is more robust, but also a little more verbose. Just use a perl one liner that uses the module and then looks up the path in the %INC variable.
$ perl -MCPAN -e 'print $INC{"CPAN.pm"}, "\n"'
/usr/lib/perl5/5.8.5/CPAN.pm
$ perl -MPod::Perldoc -e 'print $INC{"Pod/Perldoc.pm"}, "\n"'
/usr/lib/perl5/5.8.5/Pod/Perldoc.pm

No comments:

Post a Comment