NAME
Module::Path - get the full path to a locally installed module
SYNOPSIS
use Module::Path 'module_path';
$path = module_path('Test::More');
if (defined($path)) {
print "Test::More found at $path\n";
} else {
print "Danger Will Robinson!\n";
}
DESCRIPTION
Module::Path provides a single function, module_path(), which will find where a module is installed locally.
It works by looking in all the directories in @INC for an appropriately named file:
Foo::Bar becomes
Foo/Bar.pm, using the correct directory path separator for your operating system.Iterate over
@INC, ignoring any references (see "require" in "perlfunc" if you're surprised to hear that you might find references in@INC).For each directory in
@INC, append the partial path (Foo/Bar.pm), again using the correct directory path separator. If the resulting file exists, return this path.If no file was found, return
undef.
BUGS
Obviously this only works where the module you're after has its own .pm file. If a <.pm> file defines multiple packages, this won't work.
This also won't find any modules that are being loaded in some special way, for example using a code reference in @INC, as described in "require" in "perlfunc".
SEE ALSO
There are a number of other modules on CPAN which provide the same or similar functionality. But many of them provide a lot of other things, and/or they have a number of non-core dependencies. Or they're not as robust. The following is a list of the ones I'm currently aware of.
Module::Filename, Module::Overview, Module::Data, Module::Finder, Module::Info, Module::InstalledVersion, Module::Locate.
AUTHOR
Neil Bowers <neilb@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2012 by Neil Bowers <neilb@cpan.org>.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.