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
23       available 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           The Global and Cache options are no longer supported.  See the BUGS
33           section below.
34
35       locate($module_name)
36           Given a module name as a string (in standard perl bareword format)
37           locate the path of the module. If called in a scalar context the
38           first path found will be returned, if called in a list context a
39           list of paths where the module was found. Also, if references have
40           been placed in @INC then a filehandle will be returned, as defined
41           in the "require" documentation. An empty "return" is used if the
42           module couldn't be located.
43
44           As of version 1.7 a filename can also be provided to further mimic
45           the lookup behaviour of "require"/"use".
46
47       get_source($module_name)
48           When provided with a package name, gets the path using locate().
49           If locate() returned a path, then the contents of that file are
50           returned by get_source() in a scalar.
51
52       "acts_like_fh"
53           Given a scalar, check if it behaves like a filehandle. Firstly it
54           checks if it is a bareword filehandle, then if it inherits from
55           "IO::Handle" and lastly if it overloads the "<>" operator. If this
56           is missing any other standard filehandle behaviour, please send me
57           an e-mail.
58
59       mod_to_path($module_name)
60           Given a module name, converts it to a relative path e.g "Foo::Bar"
61           would become "Foo/Bar.pm".
62
63           Note that this path will always use '/' for the directory
64           separator, even on Windows, as that's the format used in %INC.
65
66       is_mod_loaded($module_name)
67           Given a module name, return true if the module has been loaded (i.e
68           exists in the %INC hash).
69
70       is_pkg_loaded($package_name)
71           Given a package name (like locate()), check if the package has an
72           existing symbol table loaded (checks by walking the %main:: stash).
73

SEE ALSO

75       A review of modules that can be used to get the path (and often other
76       information) for one or more modules:
77       <http://neilb.org/reviews/module-path.html>.
78
79       App::Module::Locate and mlocate.
80

REPOSITORY

82       <https://github.com/neilb/Module-Locate>
83

BUGS

85       In previous versions of this module, if you specified "Global => 1"
86       when use'ing this module, then looking up a module's path would update
87       %INC, even if the module hadn't actually been loaded (yet).  This meant
88       that if you subsequently tried to load the module, it would wrongly not
89       be loaded.
90
91       Bugs are tracked using RT (bug you can also raise Github issues if you
92       prefer):
93
94       <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Module-Locate>
95

AUTHOR

97       Dan Brook "<cpan@broquaint.com>"
98

LICENSE

100       This is free software; you can redistribute it and/or modify it under
101       the same terms as Perl itself.
102
103
104
105perl v5.38.0                      2023-07-20                 Module::Locate(3)
Impressum