|
Module::Locate - locate modules in the same fashion as C |
Module::Locate - locate modules in the same fashion as require and use
use Module::Locate qw/ locate get_source /;
add_plugin( locate "This::Module" );
eval 'use strict; ' . get_source('legacy_code.plx');
Using locate(), return the path that require would find for a given
module or filename (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.
This module also comes with accompanying utility functions that are used within
the module itself (except for get_source) and are available for import.
importIf :all is passed then all subroutines are exported.
If Global => BOOL is passed, then the results for module
searches i.e using locate, will also be stored in %INC, like
require. This is on by default.
If Cache => BOOL is passed, 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.
locate@INC then a filehandle will
be returned, as defined in the require documentation. An empty return is
used if the module couldn't be located.
As of version 1.7 a filename can also be provided to further mimic the lookup
behaviour of require/use.
get_sourceacts_like_fhIO::Handle and lastly if
it overloads the <> operator. If this is missing any other standard
filehandle behaviour, please send me an e-mail.
mod_to_pathFoo::Bar would become
Foo/Bar.pm.
is_mod_loadedlocate()), return true if the module has been
loaded (i.e exists in the %INC hash).
is_pkg_loadedlocate()), check if the package has an existing
symbol table loaded (checks by walking the %main:: stash).
No known bugs yet, but if you find any, please report them at:
http://rt.cpan.org/NoAuth/ReportBug.html
Dan Brook <cpan@broquaint.com>
the perl manpage, use, require
|
Module::Locate - locate modules in the same fashion as C |