NAME
Module::Locate - locate modules in the same fashion as require and use
SYNOPSIS
use Module::Locate qw/ locate get_source /;
plugin( locate "This::Module" );
munge( get_source "Another::Module::Here" );
if(locate "Some::Module") {
## do stuff
}
DESCRIPTION
Using locate(), return the path that require would find for a given module (it can also return a filehandle if a reference in @INC has been used). This means you can test for the existence, or find the path for, modules without having to evaluate the code they contain.
FUNCTIONS
import-
Given function names, the appropriate functions will be exported into the callers package.
If
Global => BOOLis passed in, then the all the results for module searche i.e usinglocate, will also be stored in%INC, just likerequire. This is on by default.If
Cache => BOOLis passed in, then every subsequent search for a module will just use the path stored in%INC, as opposed to performing another search. This is off by default.iF
:allis passed in then all subroutines are exported. locate-
Given a module (in standard perl bareword format) locate the path of the module. If called in a scalar context the first path found will be returned, if called in a list context a list of paths where the module was found. Also, if references have been placed in
@INCthen a filehandle will be returned, as defined in therequiredocumentation. An emptyreturnis used if the module couldn't be located. get_source-
When provided with a package name, retrieve the source of the
.pmthat is found. acts_like_fh-
Given a scalar, check if it behaves like a filehandle. Firstly it checks if it is a bareword filehandle, then if it inherits from
IO::Handleand lastly if it overloads the<>operator. If this is missing any other standard filehandle behaviour, please send me an e-mail. is_mod_loaded()-
Given a module (like locate()), return true if the module has been loaded (i.e exists in the
%INChash). is_pkg_loaded()-
Given a package name (like
locate()), check if the package has an existing symbol table loaded (checks by walking the%main::stash).
Changes
- 1.2
-
No longer
croak()s whenlocate()fails to find the module (which is much nicer and is consistent with the documentation).Build.PLshould now play nice withCPANinstalls
- 1.1
-
fixed
$PkgReto be functionaladded
is_mod_loaded()andis_pkg_loaded()functionsadded ':all'
import()optionhopefully fixed b0rken CPAN make process ...
- 1.0
-
Initial release
AUTHOR
Dan Brook <broquaint@hotmail.com>
SEE ALSO
perl, use, require