Module::Filename - Provides an object oriented, cross platform interface for getting a module's filename
use Module::Filename; my $filename=Module::Filename->new->filename("Test::More"); #isa Path::Class::File use Module::Filename qw{module_filename}; my $filename=module_filename("Test::More"); #isa Path::Class::File
This module returns the filename as a Path::Class::File object. It does not load any packages as it scans. It simply scans @INC looking for a module of the same name as the package passed.
use Module::Filename; my $filename=Module::Filename->new->filename("Test::More"); #isa Path::Class::File print "Test::More can be found at $filename\n";
my $mf=Module::Filename->new();
You can inherit the filename method in your package.
use base qw{Module::Filename}; sub initialize{do_something_else()};
Returns a Path::Class::File object for the first filename that matches the module in the @INC path array.
my $filename=Module::Filename->new->filename("Test::More"); #isa Path::Class::File print "Filename: $filename\n";
my $filname=module_filename("Test::More"); #isa Path::Class::File print "Filename: $filename\n";
The algorithm does not scan inside module files for provided packages.
Submit to RT and email author.
DavisNetworks.com supports all Perl applications including this package.
Michael R. Davis CPAN ID: MRDVT STOP, LLC domain=>michaelrdavis,tld=>com,account=>perl http://www.stopllc.com/
This program is free software licensed under the...
The BSD License
The full text of the license can be found in the LICENSE file included with this module.
Module::Filename predates Module::Path by almost 4 years but it appears more people prefer Module::Path over Module::Filename as it does not have the dependency on Path::Class. After the reviews on http://neilb.org/reviews/module-path.html. I added the functional API to Module::Filename. So, your decision is simply an object/non-object decision. The operations with the file system that both packages perform outweigh the performance of the object creation in Module::Filename. So, any performance penalty should not be measurable. Since Module::Filename does not need three extra file test operations that Module::Path 0.18 performs on each @INC directory, Module::Filename may actually be faster than Module::Path for most applications.
Module::Path, perlvar %INC, pmpath, Module::Info constructor=>new_from_module, method=>file, Module::InstalledVersion property=>"dir", Module::Locate method=>locate, Module::Util method=>find_installed
CPAN modules for getting a module's path http://neilb.org/reviews/module-path.html
To install Module::Filename, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Module::Filename
CPAN shell
perl -MCPAN -e shell install Module::Filename
For more information on module installation, please visit the detailed CPAN module installation guide.