📄 pod::simple::search.3
字号:
names begin with \*(L"\s-1LW\s0\*(R"; or you might search for \*(L"*Find*\*(R" to search forall modules with \*(L"Find\*(R" somewhere in their full name. (You can also use\&\*(L"?\*(R" in a glob expression; so \*(L"\s-1DB\s0?\*(R" will match \*(L"\s-1DBI\s0\*(R" and \*(L"\s-1DBD\s0\*(R".).ie n .IP "$search\fR\->callback( \fI\e&some_routine );" 4.el .IP "\f(CW$search\fR\->callback( \fI\e&some_routine\fR );" 4.IX Item "$search->callback( &some_routine );"This attribute means that every time this search sees a matchingPod file, it should call this callback routine. The routine is calledwith two parameters: the current file's filespec, and its pod name.(For example: \f(CW\*(C`("/etc/perljunk/File/Crunk.pm", "File::Crunk")\*(C'\fR wouldbe in \f(CW@_\fR.).SpThe callback routine's return value is not used for anything..SpThis attribute's default value is false, meaning that no callbackis called..ie n .IP "$search\fR\->laborious( \fItrue-or-false );" 4.el .IP "\f(CW$search\fR\->laborious( \fItrue-or-false\fR );" 4.IX Item "$search->laborious( true-or-false );"Unless you set this attribute to a true value, Pod::Search will apply Perl-specific heuristics to find the correct module PODs quickly.This attribute's default value is false. You won't normally needto set this to true..SpSpecifically: Turning on this option will disable the heuristics forseeing only files with Perl-like extensions, omitting subdirectoriesthat are numeric but do \fInot\fR match the current Perl interpreter'sversion \s-1ID\s0, suppressing \fIsite_perl\fR as a module hierarchy name, etc..ie n .IP "$search\fR\->shadows( \fItrue-or-false );" 4.el .IP "\f(CW$search\fR\->shadows( \fItrue-or-false\fR );" 4.IX Item "$search->shadows( true-or-false );"Unless you set this attribute to a true value, Pod::Simple::Search willconsider only the first file of a given modulename as it looks thru thespecified directories; that is, with this option off, ifPod::Simple::Search has seen a \f(CW\*(C`somepathdir/Foo/Bar.pm\*(C'\fR already in thissearch, then it won't bother looking at a \f(CW\*(C`somelaterpathdir/Foo/Bar.pm\*(C'\fRlater on in that search, because that file is merely a \*(L"shadow\*(R". But ifyou turn on \f(CW\*(C`$self\->shadows(1)\*(C'\fR, then these \*(L"shadow\*(R" files areinspected too, and are noted in the pathname2podname return hash..SpThis attribute's default value is false; and normally you won'tneed to turn it on..ie n .IP "$search\fR\->limit_re( \fIsome-regxp );" 4.el .IP "\f(CW$search\fR\->limit_re( \fIsome-regxp\fR );" 4.IX Item "$search->limit_re( some-regxp );"Setting this attribute (to a value that's a regexp) means that you wantto limit the results just to items whose podnames match the givenregexp. Normally this option is not needed, and the more efficient\&\f(CW\*(C`limit_glob\*(C'\fR attribute is used instead..ie n .IP "$search\fR\->dir_prefix( \fIsome-string-value );" 4.el .IP "\f(CW$search\fR\->dir_prefix( \fIsome-string-value\fR );" 4.IX Item "$search->dir_prefix( some-string-value );"Setting this attribute to a string value means that the searches shouldbegin in the specified subdirectory name (like \*(L"Pod\*(R" or \*(L"File::Find\*(R",also expressable as \*(L"File/Find\*(R"). For example, the search option\&\f(CW\*(C`$search\->limit_glob("File::Find::R*")\*(C'\fRis the same as the combination of the search options\&\f(CW\*(C`$search\->limit_re("^File::Find::R") \-> dir_prefix("File::Find")\*(C'\fR..SpNormally you don't need to know about the \f(CW\*(C`dir_prefix\*(C'\fR option, but Iinclude it in case it might prove useful for someone somewhere..Sp(Implementationally, searching with limit_glob ends up setting limit_reand usually dir_prefix.).ie n .IP "$search\fR\->progress( \fIsome-progress-object );" 4.el .IP "\f(CW$search\fR\->progress( \fIsome-progress-object\fR );" 4.IX Item "$search->progress( some-progress-object );"If you set a value for this attribute, the value is expectedto be an object (probably of a class that you define) that has a \&\f(CW\*(C`reach\*(C'\fR method and a \f(CW\*(C`done\*(C'\fR method. This is meant for reportingprogress during the search, if you don't want to use a simplecallback..SpNormally you don't need to know about the \f(CW\*(C`progress\*(C'\fR option, but Iinclude it in case it might prove useful for someone somewhere..SpWhile a search is in progress, the progress object's \f(CW\*(C`reach\*(C'\fR and\&\f(CW\*(C`done\*(C'\fR methods are called like this:.Sp.Vb 2\& # Every time a file is being scanned for pod:\& $progress\->reach($count, "Scanning $file"); ++$count;\&\& # And then at the end of the search:\& $progress\->done("Noted $count Pod files total");.Ve.SpInternally, we often set this to an object of classPod::Simple::Progress. That class is probably undocumented,but you may wish to look at its source..ie n .IP "$name2path\fR = \f(CW$self\->name2path;" 4.el .IP "\f(CW$name2path\fR = \f(CW$self\fR\->name2path;" 4.IX Item "$name2path = $self->name2path;"This attribute is not a search parameter, but is used to report theresult of \f(CW\*(C`survey\*(C'\fR method, as discussed in the next section..ie n .IP "$path2name\fR = \f(CW$self\->path2name;" 4.el .IP "\f(CW$path2name\fR = \f(CW$self\fR\->path2name;" 4.IX Item "$path2name = $self->path2name;"This attribute is not a search parameter, but is used to report theresult of \f(CW\*(C`survey\*(C'\fR method, as discussed in the next section..SH "MAIN SEARCH METHODS".IX Header "MAIN SEARCH METHODS"Once you've actually set any options you want (if any), you can goahead and use the following methods to search for Pod filesin particular ways..ie n .Sh """$search\->survey( @directories )""".el .Sh "\f(CW$search\->survey( @directories )\fP".IX Subsection "$search->survey( @directories )"The method \f(CW\*(C`survey\*(C'\fR searches for \s-1POD\s0 documents in a given set offiles and/or directories. This runs the search according to the variousoptions set by the accessors above. (For example, if the \f(CW\*(C`inc\*(C'\fR attributeis on, as it is by default, then the perl \f(CW@INC\fR directories are implicitlyadded to the list of directories (if any) that you specify.).PPThe return value of \f(CW\*(C`survey\*(C'\fR is two hashes:.ie n .IP """name2path""" 4.el .IP "\f(CWname2path\fR" 4.IX Item "name2path"A hash that maps from each pod-name to the filespec (like\&\*(L"Stuff::Thing\*(R" => \*(L"/whatever/plib/Stuff/Thing.pm\*(R").ie n .IP """path2name""" 4.el .IP "\f(CWpath2name\fR" 4.IX Item "path2name"A hash that maps from each Pod filespec to its pod-name (like\&\*(L"/whatever/plib/Stuff/Thing.pm\*(R" => \*(L"Stuff::Thing\*(R").PPBesides saving these hashes as the hashref attributes\&\f(CW\*(C`name2path\*(C'\fR and \f(CW\*(C`path2name\*(C'\fR, calling this function also returnsthese hashrefs. In list context, the return value of\&\f(CW\*(C`$search\->survey\*(C'\fR is the list \f(CW\*(C`(\e%name2path, \e%path2name)\*(C'\fR.In scalar context, the return value is \f(CW\*(C`\e%name2path\*(C'\fR.Or you can just call this in void context..PPRegardless of calling context, calling \f(CW\*(C`survey\*(C'\fR savesits results in its \f(CW\*(C`name2path\*(C'\fR and \f(CW\*(C`path2name\*(C'\fR attributes..PPE.g., when searching in \fI\f(CI$HOME\fI/perl5lib\fR, the file\&\fI\f(CI$HOME\fI/perl5lib/MyModule.pm\fR would get the \s-1POD\s0 name \fIMyModule\fR,whereas \fI\f(CI$HOME\fI/perl5lib/Myclass/Subclass.pm\fR would be\&\fIMyclass::Subclass\fR. The name information can be used for \s-1POD\s0translators..PPOnly text files containing at least one valid \s-1POD\s0 command are found..PPIn verbose mode, a warning is printed if shadows are found (i.e., morethan one \s-1POD\s0 file with the same \s-1POD\s0 name is found, e.g. \fI\s-1CPAN\s0.pm\fR indifferent directories). This usually indicates duplicate occurrences ofmodules in the \fI\f(CI@INC\fI\fR search path, which is occasionally inadvertent(but is often simply a case of a user's path dir having a more recentversion than the system's general path dirs in general.).PPThe options to this argument is a list of either directories that aresearched recursively, or files. (Usually you wouldn't specify files,but just dirs.) Or you can just specify an empty-list, as in\&\f(CW$name2path\fR; with the\&\f(CW\*(C`inc\*(C'\fR option on, as it is by default, teh.PPThe \s-1POD\s0 names of files are the plain basenames with any Perl-likeextension (.pm, .pl, .pod) stripped, and path separators replaced by\&\f(CW\*(C`::\*(C'\fR's..PPCalling Pod::Simple::Search\->search(...) is short forPod::Simple::Search\->new\->search(...). That is, a throwaway objectwith default attribute values is used..ie n .Sh """$search\->simplify_name( $str )""".el .Sh "\f(CW$search\->simplify_name( $str )\fP".IX Subsection "$search->simplify_name( $str )"The method \fBsimplify_name\fR is equivalent to \fBbasename\fR, but alsostrips Perl-like extensions (.pm, .pl, .pod) and extensions like\&\fI.bat\fR, \fI.cmd\fR on Win32 and \s-1OS/2\s0, or \fI.com\fR on \s-1VMS\s0, respectively..ie n .Sh """$search\->find( $pod )""".el .Sh "\f(CW$search\->find( $pod )\fP".IX Subsection "$search->find( $pod )".ie n .Sh """$search\->find( $pod, @search_dirs )""".el .Sh "\f(CW$search\->find( $pod, @search_dirs )\fP".IX Subsection "$search->find( $pod, @search_dirs )"Returns the location of a Pod file, given a Pod/module/script name(like \*(L"Foo::Bar\*(R" or \*(L"perlvar\*(R" or \*(L"perldoc\*(R"), and an idea ofwhat files/directories to look in.It searches according to the various options set by the accessors above.(For example, if the \f(CW\*(C`inc\*(C'\fR attribute is on, as it is by default, thenthe perl \f(CW@INC\fR directories are implicitly added to the list ofdirectories (if any) that you specify.).PPThis returns the full path of the first occurrence to the file.Package names (eg 'A::B') are automatically converted to directorynames in the selected directory. Additionally, '.pm', '.pl' and '.pod'are automatically appended to the search as required.(So, for example, under Unix, \*(L"A::B\*(R" is converted to \*(L"somedir/A/B.pm\*(R",\&\*(L"somedir/A/B.pod\*(R", or \*(L"somedir/A/B.pl\*(R", as appropriate.).PPIf no such Pod file is found, this method returns undef..PPIf any of the given search directories contains a \fIpod/\fR subdirectory,then it is searched. (That's how we manage to find \fIperlfunc\fR,for example, which is usually in \fIpod/perlfunc\fR in most Perl dists.).PPThe \f(CW\*(C`verbose\*(C'\fR and \f(CW\*(C`inc\*(C'\fR attributes influence the behavior of thissearch; notably, \f(CW\*(C`inc\*(C'\fR, if true, adds \f(CW@INC\fR \fIand also\&\f(CI$Config::Config\fI{'scriptdir'}\fR to the list of directories to search..PPIt is common to simply say \f(CW\*(C`$filename = Pod::Simple::Search\-> new \&\->find("perlvar")\*(C'\fR so that just the \f(CW@INC\fR (well, and scriptdir)directories are searched. (This happens because the \f(CW\*(C`inc\*(C'\fRattribute is true by default.).PPCalling Pod::Simple::Search\->find(...) is short forPod::Simple::Search\->new\->find(...). That is, a throwaway objectwith default attribute values is used..ie n .Sh """$self\->contains_pod( $file )""".el .Sh "\f(CW$self\->contains_pod( $file )\fP".IX Subsection "$self->contains_pod( $file )"Returns true if the supplied filename (not \s-1POD\s0 module) contains some Poddocumentation..SH "AUTHOR".IX Header "AUTHOR"Sean M. Burke <sburke@cpan.org>borrowed code fromMarek Rouchal's Pod::Find, which in turnheavily borrowed code from Nick Ing\-Simmons' PodToHtml..PPTim Jenness <t.jenness@jach.hawaii.edu> provided\&\f(CW\*(C`find\*(C'\fR and \f(CW\*(C`contains_pod\*(C'\fR to Pod::Find..SH "SEE ALSO".IX Header "SEE ALSO"Pod::Simple, Pod::Perldoc
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -