1Pod::Simple::Search(3)User Contributed Perl DocumentationPod::Simple::Search(3)
2
3
4

NAME

6       Pod::Simple::Search - find POD documents in directory trees
7

SYNOPSIS

9         use Pod::Simple::Search;
10         my $name2path = Pod::Simple::Search->new->limit_glob('LWP::*')->survey;
11         print "Looky see what I found: ",
12           join(' ', sort keys %$name2path), "\n";
13
14         print "LWPUA docs = ",
15           Pod::Simple::Search->new->find('LWP::UserAgent') || "?",
16           "\n";
17

DESCRIPTION

19       Pod::Simple::Search is a class that you use for running searches for
20       Pod files.  An object of this class has several attributes (mostly
21       options for controlling search options), and some methods for searching
22       based on those attributes.
23
24       The way to use this class is to make a new object of this class, set
25       any options, and then call one of the search options (probably "survey"
26       or "find").  The sections below discuss the syntaxes for doing all
27       that.
28

CONSTRUCTOR

30       This class provides the one constructor, called "new".  It takes no
31       parameters:
32
33         use Pod::Simple::Search;
34         my $search = Pod::Simple::Search->new;
35

ACCESSORS

37       This class defines several methods for setting (and, occasionally,
38       reading) the contents of an object. With two exceptions (discussed at
39       the end of this section), these attributes are just for controlling the
40       way searches are carried out.
41
42       Note that each of these return $self when you call them as
43       "$self->whatever(value)".  That's so that you can chain together set-
44       attribute calls like this:
45
46         my $name2path =
47           Pod::Simple::Search->new
48           -> inc(0) -> verbose(1) -> callback(\&blab)
49           ->survey(@there);
50
51       ...which works exactly as if you'd done this:
52
53         my $search = Pod::Simple::Search->new;
54         $search->inc(0);
55         $search->verbose(1);
56         $search->callback(\&blab);
57         my $name2path = $search->survey(@there);
58
59       $search->inc( true-or-false );
60           This attribute, if set to a true value, means that searches should
61           implicitly add perl's @INC paths. This automatically considers
62           paths specified in the "PERL5LIB" environment as this is prepended
63           to @INC by the Perl interpreter itself.  This attribute's default
64           value is TRUE.  If you want to search only specific directories,
65           set $self->inc(0) before calling $inc->survey or $inc->find.
66
67       $search->verbose( nonnegative-number );
68           This attribute, if set to a nonzero positive value, will make
69           searches output (via "warn") notes about what they're doing as they
70           do it.  This option may be useful for debugging a pod-related
71           module.  This attribute's default value is zero, meaning that no
72           "warn" messages are produced.  (Setting verbose to 1 turns on some
73           messages, and setting it to 2 turns on even more messages, i.e.,
74           makes the following search(es) even more verbose than 1 would make
75           them.)
76
77       $search->limit_glob( some-glob-string );
78           This option means that you want to limit the results just to items
79           whose podnames match the given glob/wildcard expression. For
80           example, you might limit your search to just "LWP::*", to search
81           only for modules starting with "LWP::*" (but not including the
82           module "LWP" itself); or you might limit your search to "LW*" to
83           see only modules whose (full) names begin with "LW"; or you might
84           search for "*Find*" to search for all modules with "Find" somewhere
85           in their full name. (You can also use "?" in a glob expression; so
86           "DB?" will match "DBI" and "DBD".)
87
88       $search->callback( \&some_routine );
89           This attribute means that every time this search sees a matching
90           Pod file, it should call this callback routine.  The routine is
91           called with two parameters: the current file's filespec, and its
92           pod name.  (For example: "("/etc/perljunk/File/Crunk.pm",
93           "File::Crunk")" would be in @_.)
94
95           The callback routine's return value is not used for anything.
96
97           This attribute's default value is false, meaning that no callback
98           is called.
99
100       $search->laborious( true-or-false );
101           Unless you set this attribute to a true value, Pod::Search will
102           apply Perl-specific heuristics to find the correct module PODs
103           quickly.  This attribute's default value is false.  You won't
104           normally need to set this to true.
105
106           Specifically: Turning on this option will disable the heuristics
107           for seeing only files with Perl-like extensions, omitting
108           subdirectories that are numeric but do not match the current Perl
109           interpreter's version ID, suppressing site_perl as a module
110           hierarchy name, etc.
111
112       $search->recurse( true-or-false );
113           Unless you set this attribute to a false value, Pod::Search will
114           recurse into subdirectories of the search directories.
115
116       $search->shadows( true-or-false );
117           Unless you set this attribute to a true value, Pod::Simple::Search
118           will consider only the first file of a given modulename as it looks
119           thru the specified directories; that is, with this option off, if
120           Pod::Simple::Search has seen a "somepathdir/Foo/Bar.pm" already in
121           this search, then it won't bother looking at a
122           "somelaterpathdir/Foo/Bar.pm" later on in that search, because that
123           file is merely a "shadow". But if you turn on "$self->shadows(1)",
124           then these "shadow" files are inspected too, and are noted in the
125           pathname2podname return hash.
126
127           This attribute's default value is false; and normally you won't
128           need to turn it on.
129
130       $search->limit_re( some-regxp );
131           Setting this attribute (to a value that's a regexp) means that you
132           want to limit the results just to items whose podnames match the
133           given regexp. Normally this option is not needed, and the more
134           efficient "limit_glob" attribute is used instead.
135
136       $search->dir_prefix( some-string-value );
137           Setting this attribute to a string value means that the searches
138           should begin in the specified subdirectory name (like "Pod" or
139           "File::Find", also expressible as "File/Find"). For example, the
140           search option "$search->limit_glob("File::Find::R*")" is the same
141           as the combination of the search options
142           "$search->limit_re("^File::Find::R") -> dir_prefix("File::Find")".
143
144           Normally you don't need to know about the "dir_prefix" option, but
145           I include it in case it might prove useful for someone somewhere.
146
147           (Implementationally, searching with limit_glob ends up setting
148           limit_re and usually dir_prefix.)
149
150       $search->progress( some-progress-object );
151           If you set a value for this attribute, the value is expected to be
152           an object (probably of a class that you define) that has a "reach"
153           method and a "done" method.  This is meant for reporting progress
154           during the search, if you don't want to use a simple callback.
155
156           Normally you don't need to know about the "progress" option, but I
157           include it in case it might prove useful for someone somewhere.
158
159           While a search is in progress, the progress object's "reach" and
160           "done" methods are called like this:
161
162             # Every time a file is being scanned for pod:
163             $progress->reach($count, "Scanning $file");   ++$count;
164
165             # And then at the end of the search:
166             $progress->done("Noted $count Pod files total");
167
168           Internally, we often set this to an object of class
169           Pod::Simple::Progress.  That class is probably undocumented, but
170           you may wish to look at its source.
171
172       $name2path = $self->name2path;
173           This attribute is not a search parameter, but is used to report the
174           result of "survey" method, as discussed in the next section.
175
176       $path2name = $self->path2name;
177           This attribute is not a search parameter, but is used to report the
178           result of "survey" method, as discussed in the next section.
179

MAIN SEARCH METHODS

181       Once you've actually set any options you want (if any), you can go
182       ahead and use the following methods to search for Pod files in
183       particular ways.
184
185   "$search->survey( @directories )"
186       The method "survey" searches for POD documents in a given set of files
187       and/or directories.  This runs the search according to the various
188       options set by the accessors above.  (For example, if the "inc"
189       attribute is on, as it is by default, then the perl @INC directories
190       are implicitly added to the list of directories (if any) that you
191       specify.)
192
193       The return value of "survey" is two hashes:
194
195       "name2path"
196           A hash that maps from each pod-name to the filespec (like
197           "Stuff::Thing" => "/whatever/plib/Stuff/Thing.pm")
198
199       "path2name"
200           A hash that maps from each Pod filespec to its pod-name (like
201           "/whatever/plib/Stuff/Thing.pm" => "Stuff::Thing")
202
203       Besides saving these hashes as the hashref attributes "name2path" and
204       "path2name", calling this function also returns these hashrefs.  In
205       list context, the return value of "$search->survey" is the list
206       "(\%name2path, \%path2name)".  In scalar context, the return value is
207       "\%name2path".  Or you can just call this in void context.
208
209       Regardless of calling context, calling "survey" saves its results in
210       its "name2path" and "path2name" attributes.
211
212       E.g., when searching in $HOME/perl5lib, the file
213       $HOME/perl5lib/MyModule.pm would get the POD name MyModule, whereas
214       $HOME/perl5lib/Myclass/Subclass.pm would be Myclass::Subclass. The name
215       information can be used for POD translators.
216
217       Only text files containing at least one valid POD command are found.
218
219       In verbose mode, a warning is printed if shadows are found (i.e., more
220       than one POD file with the same POD name is found, e.g. CPAN.pm in
221       different directories).  This usually indicates duplicate occurrences
222       of modules in the @INC search path, which is occasionally inadvertent
223       (but is often simply a case of a user's path dir having a more recent
224       version than the system's general path dirs in general.)
225
226       The options to this argument is a list of either directories that are
227       searched recursively, or files.  (Usually you wouldn't specify files,
228       but just dirs.)  Or you can just specify an empty-list, as in
229       $name2path; with the "inc" option on, as it is by default.
230
231       The POD names of files are the plain basenames with any Perl-like
232       extension (.pm, .pl, .pod) stripped, and path separators replaced by
233       "::"'s.
234
235       Calling Pod::Simple::Search->search(...) is short for
236       Pod::Simple::Search->new->search(...).  That is, a throwaway object
237       with default attribute values is used.
238
239   "$search->simplify_name( $str )"
240       The method simplify_name is equivalent to basename, but also strips
241       Perl-like extensions (.pm, .pl, .pod) and extensions like .bat, .cmd on
242       Win32 and OS/2, or .com on VMS, respectively.
243
244   "$search->find( $pod )"
245   "$search->find( $pod, @search_dirs )"
246       Returns the location of a Pod file, given a Pod/module/script name
247       (like "Foo::Bar" or "perlvar" or "perldoc"), and an idea of what
248       files/directories to look in.  It searches according to the various
249       options set by the accessors above.  (For example, if the "inc"
250       attribute is on, as it is by default, then the perl @INC directories
251       are implicitly added to the list of directories (if any) that you
252       specify.)
253
254       This returns the full path of the first occurrence to the file.
255       Package names (eg 'A::B') are automatically converted to directory
256       names in the selected directory.  Additionally, '.pm', '.pl' and '.pod'
257       are automatically appended to the search as required.  (So, for
258       example, under Unix, "A::B" is converted to "somedir/A/B.pm",
259       "somedir/A/B.pod", or "somedir/A/B.pl", as appropriate.)
260
261       If no such Pod file is found, this method returns undef.
262
263       If any of the given search directories contains a pod/ subdirectory,
264       then it is searched.  (That's how we manage to find perlfunc, for
265       example, which is usually in pod/perlfunc in most Perl dists.)
266
267       The "verbose" and "inc" attributes influence the behavior of this
268       search; notably, "inc", if true, adds @INC and also
269       $Config::Config{'scriptdir'} to the list of directories to search.
270
271       It is common to simply say "$filename = Pod::Simple::Search-> new
272       ->find("perlvar")" so that just the @INC (well, and scriptdir)
273       directories are searched.  (This happens because the "inc" attribute is
274       true by default.)
275
276       Calling Pod::Simple::Search->find(...) is short for
277       Pod::Simple::Search->new->find(...).  That is, a throwaway object with
278       default attribute values is used.
279
280   "$self->contains_pod( $file )"
281       Returns true if the supplied filename (not POD module) contains some
282       Pod documentation.
283

SUPPORT

285       Questions or discussion about POD and Pod::Simple should be sent to the
286       pod-people@perl.org mail list. Send an empty email to
287       pod-people-subscribe@perl.org to subscribe.
288
289       This module is managed in an open GitHub repository,
290       <https://github.com/perl-pod/pod-simple/>. Feel free to fork and
291       contribute, or to clone <git://github.com/perl-pod/pod-simple.git> and
292       send patches!
293
294       Patches against Pod::Simple are welcome. Please send bug reports to
295       <bug-pod-simple@rt.cpan.org>.
296
298       Copyright (c) 2002 Sean M. Burke.
299
300       This library is free software; you can redistribute it and/or modify it
301       under the same terms as Perl itself.
302
303       This program is distributed in the hope that it will be useful, but
304       without any warranty; without even the implied warranty of
305       merchantability or fitness for a particular purpose.
306

AUTHOR

308       Pod::Simple was created by Sean M. Burke <sburke@cpan.org> with code
309       borrowed from Marek Rouchal's Pod::Find, which in turn heavily borrowed
310       code from Nick Ing-Simmons' "PodToHtml".
311
312       But don't bother him, he's retired.
313
314       Pod::Simple is maintained by:
315
316       ·   Allison Randal "allison@perl.org"
317
318       ·   Hans Dieter Pearcey "hdp@cpan.org"
319
320       ·   David E. Wheeler "dwheeler@cpan.org"
321
322
323
324perl v5.26.3                      2016-11-29            Pod::Simple::Search(3)
Impressum