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->shadows( true-or-false );
113           Unless you set this attribute to a true value, Pod::Simple::Search
114           will consider only the first file of a given modulename as it looks
115           thru the specified directories; that is, with this option off, if
116           Pod::Simple::Search has seen a "somepathdir/Foo/Bar.pm" already in
117           this search, then it won't bother looking at a
118           "somelaterpathdir/Foo/Bar.pm" later on in that search, because that
119           file is merely a "shadow". But if you turn on "$self->shadows(1)",
120           then these "shadow" files are inspected too, and are noted in the
121           pathname2podname return hash.
122
123           This attribute's default value is false; and normally you won't
124           need to turn it on.
125
126       $search->limit_re( some-regxp );
127           Setting this attribute (to a value that's a regexp) means that you
128           want to limit the results just to items whose podnames match the
129           given regexp. Normally this option is not needed, and the more
130           efficient "limit_glob" attribute is used instead.
131
132       $search->dir_prefix( some-string-value );
133           Setting this attribute to a string value means that the searches
134           should begin in the specified subdirectory name (like "Pod" or
135           "File::Find", also expressable as "File/Find"). For example, the
136           search option "$search->limit_glob("File::Find::R*")" is the same
137           as the combination of the search options
138           "$search->limit_re("^File::Find::R") -> dir_prefix("File::Find")".
139
140           Normally you don't need to know about the "dir_prefix" option, but
141           I include it in case it might prove useful for someone somewhere.
142
143           (Implementationally, searching with limit_glob ends up setting
144           limit_re and usually dir_prefix.)
145
146       $search->progress( some-progress-object );
147           If you set a value for this attribute, the value is expected to be
148           an object (probably of a class that you define) that has a "reach"
149           method and a "done" method.  This is meant for reporting progress
150           during the search, if you don't want to use a simple callback.
151
152           Normally you don't need to know about the "progress" option, but I
153           include it in case it might prove useful for someone somewhere.
154
155           While a search is in progress, the progress object's "reach" and
156           "done" methods are called like this:
157
158             # Every time a file is being scanned for pod:
159             $progress->reach($count, "Scanning $file");   ++$count;
160
161             # And then at the end of the search:
162             $progress->done("Noted $count Pod files total");
163
164           Internally, we often set this to an object of class
165           Pod::Simple::Progress.  That class is probably undocumented, but
166           you may wish to look at its source.
167
168       $name2path = $self->name2path;
169           This attribute is not a search parameter, but is used to report the
170           result of "survey" method, as discussed in the next section.
171
172       $path2name = $self->path2name;
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

MAIN SEARCH METHODS

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

AUTHOR

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