1Module::Locate(3)     User Contributed Perl Documentation    Module::Locate(3)
2
3
4

NAME

6       Module::Locate - locate modules in the same fashion as "require" and
7       "use"
8

SYNOPSIS

10         use Module::Locate qw/ locate get_source /;
11
12         add_plugin( locate "This::Module" );
13         eval 'use strict; ' . get_source('legacy_code.plx');
14

DESCRIPTION

16       Using "locate()", return the path that "require" would find for a given
17       module or filename (it can also return a filehandle if a reference in
18       @INC has been used). This means you can test for the existence, or find
19       the path for, modules without having to evaluate the code they contain.
20
21       This module also comes with accompanying utility functions that are
22       used within the module itself (except for "get_source") and are avail‐
23       able for import.
24

FUNCTIONS

26       "import"
27           Given function names, the appropriate functions will be exported
28           into the caller's package.
29
30           If ":all" is passed then all subroutines are exported.
31
32           If "Global => BOOL" is passed, then the results for module searches
33           i.e using "locate", will also be stored in %INC, like "require".
34           This is on by default.
35
36           If "Cache => BOOL" is passed, then every subsequent search for a
37           module will just use the path stored in %INC, as opposed to per‐
38           forming another search. This is off by default.
39
40       "locate"
41           Given a module name as a string (in standard perl bareword format)
42           locate the path of the module. If called in a scalar context the
43           first path found will be returned, if called in a list context a
44           list of paths where the module was found. Also, if references have
45           been placed in @INC then a filehandle will be returned, as defined
46           in the "require" documentation. An empty "return" is used if the
47           module couldn't be located.
48
49           As of version 1.7 a filename can also be provided to further mimic
50           the lookup behaviour of "require"/"use".
51
52       "get_source"
53           When provided with a package name, retrieve the source of the mod‐
54           ule that is found.
55
56       "acts_like_fh"
57           Given a scalar, check if it behaves like a filehandle. Firstly it
58           checks if it is a bareword filehandle, then if it inherits from
59           "IO::Handle" and lastly if it overloads the "<>" operator. If this
60           is missing any other standard filehandle behaviour, please send me
61           an e-mail.
62
63       "mod_to_path"
64           Given a module name convert it to a relative path e.g "Foo::Bar"
65           would become "Foo/Bar.pm".
66
67       "is_mod_loaded"
68           Given a module name (like "locate()"), return true if the module
69           has been loaded (i.e exists in the %INC hash).
70
71       "is_pkg_loaded"
72           Given a package name (like "locate()"), check if the package has an
73           existing symbol table loaded (checks by walking the %main:: stash).
74

BUGS

76       No known bugs yet, but if you find any, please report them at:
77
78       <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Module-Locate>
79

AUTHOR

81       Dan Brook "<cpan@broquaint.com>"
82

SEE ALSO

84       perl, "use", "require"
85
86
87
88perl v5.8.8                       2005-07-02                 Module::Locate(3)
Impressum