.\" Automatically generated by Pod::Man 4.11 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Pod::Select 3perl" .TH Pod::Select 3perl "2020-06-07" "perl v5.30.3" "Perl Programmers Reference Guide" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Pod::Select, podselect() \- extract selected sections of POD from input .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use Pod::Select; \& \& ## Select all the POD sections for each file in @filelist \& ## and print the result on standard output. \& podselect(@filelist); \& \& ## Same as above, but write to tmp.out \& podselect({\-output => "tmp.out"}, @filelist): \& \& ## Select from the given filelist, only those POD sections that are \& ## within a 1st level section named any of: NAME, SYNOPSIS, OPTIONS. \& podselect({\-sections => ["NAME|SYNOPSIS", "OPTIONS"]}, @filelist): \& \& ## Select the "DESCRIPTION" section of the PODs from STDIN and write \& ## the result to STDERR. \& podselect({\-output => ">&STDERR", \-sections => ["DESCRIPTION"]}, \e*STDIN); .Ve .PP or .PP .Vb 1 \& use Pod::Select; \& \& ## Create a parser object for selecting POD sections from the input \& $parser = new Pod::Select(); \& \& ## Select all the POD sections for each file in @filelist \& ## and print the result to tmp.out. \& $parser\->parse_from_file("<&STDIN", "tmp.out"); \& \& ## Select from the given filelist, only those POD sections that are \& ## within a 1st level section named any of: NAME, SYNOPSIS, OPTIONS. \& $parser\->select("NAME|SYNOPSIS", "OPTIONS"); \& for (@filelist) { $parser\->parse_from_file($_); } \& \& ## Select the "DESCRIPTION" and "SEE ALSO" sections of the PODs from \& ## STDIN and write the result to STDERR. \& $parser\->select("DESCRIPTION"); \& $parser\->add_selection("SEE ALSO"); \& $parser\->parse_from_filehandle(\e*STDIN, \e*STDERR); .Ve .SH "REQUIRES" .IX Header "REQUIRES" perl5.005, Pod::Parser, Exporter, Carp .SH "EXPORTS" .IX Header "EXPORTS" \&\fBpodselect()\fR .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fB\s-1NOTE:\s0 This module is considered legacy; modern Perl releases (5.18 and higher) are going to remove Pod-Parser from core and use Pod-Simple for all things \s-1POD.\s0\fR .PP \&\fB\fBpodselect()\fB\fR is a function which will extract specified sections of pod documentation from an input stream. This ability is provided by the \&\fBPod::Select\fR module which is a subclass of \fBPod::Parser\fR. \&\fBPod::Select\fR provides a method named \fB\fBselect()\fB\fR to specify the set of \&\s-1POD\s0 sections to select for processing/printing. \fB\fBpodselect()\fB\fR merely creates a \fBPod::Select\fR object and then invokes the \fB\fBpodselect()\fB\fR followed by \fB\fBparse_from_file()\fB\fR. .SH "SECTION SPECIFICATIONS" .IX Header "SECTION SPECIFICATIONS" \&\fB\fBpodselect()\fB\fR and \fB\fBPod::Select::select()\fB\fR may be given one or more \&\*(L"section specifications\*(R" to restrict the text processed to only the desired set of sections and their corresponding subsections. A section specification is a string containing one or more Perl-style regular expressions separated by forward slashes (\*(L"/\*(R"). If you need to use a forward slash literally within a section title you can escape it with a backslash (\*(L"\e/\*(R"). .PP The formal syntax of a section specification is: .IP "\(bu" 4 \&\fIhead1\-title\-regex\fR/\fIhead2\-title\-regex\fR/... .PP Any omitted or empty regular expressions will default to \*(L".*\*(R". Please note that each regular expression given is implicitly anchored by adding \*(L"^\*(R" and \*(L"$\*(R" to the beginning and end. Also, if a given regular expression starts with a \*(L"!\*(R" character, then the expression is \fInegated\fR (so \f(CW\*(C`!foo\*(C'\fR would match anything \fIexcept\fR \&\f(CW\*(C`foo\*(C'\fR). .PP Some example section specifications follow. .IP "\(bu" 4 Match the \f(CW\*(C`NAME\*(C'\fR and \f(CW\*(C`SYNOPSIS\*(C'\fR sections and all of their subsections: .Sp \&\f(CW\*(C`NAME|SYNOPSIS\*(C'\fR .IP "\(bu" 4 Match only the \f(CW\*(C`Question\*(C'\fR and \f(CW\*(C`Answer\*(C'\fR subsections of the \f(CW\*(C`DESCRIPTION\*(C'\fR section: .Sp \&\f(CW\*(C`DESCRIPTION/Question|Answer\*(C'\fR .IP "\(bu" 4 Match the \f(CW\*(C`Comments\*(C'\fR subsection of \fIall\fR sections: .Sp \&\f(CW\*(C`/Comments\*(C'\fR .IP "\(bu" 4 Match all subsections of \f(CW\*(C`DESCRIPTION\*(C'\fR \fIexcept\fR for \f(CW\*(C`Comments\*(C'\fR: .Sp \&\f(CW\*(C`DESCRIPTION/!Comments\*(C'\fR .IP "\(bu" 4 Match the \f(CW\*(C`DESCRIPTION\*(C'\fR section but do \fInot\fR match any of its subsections: .Sp \&\f(CW\*(C`DESCRIPTION/!.+\*(C'\fR .IP "\(bu" 4 Match all top level sections but none of their subsections: .Sp \&\f(CW\*(C`/!.+\*(C'\fR .SH "OBJECT METHODS" .IX Header "OBJECT METHODS" The following methods are provided in this module. Each one takes a reference to the object itself as an implicit first parameter. .SH "\fBcurr_headings()\fP" .IX Header "curr_headings()" .Vb 2 \& ($head1, $head2, $head3, ...) = $parser\->curr_headings(); \& $head1 = $parser\->curr_headings(1); .Ve .PP This method returns a list of the currently active section headings and subheadings in the document being parsed. The list of headings returned corresponds to the most recently parsed paragraph of the input. .PP If an argument is given, it must correspond to the desired section heading number, in which case only the specified section heading is returned. If there is no current section heading at the specified level, then \f(CW\*(C`undef\*(C'\fR is returned. .SH "\fBselect()\fP" .IX Header "select()" .Vb 1 \& $parser\->select($section_spec1,$section_spec2,...); .Ve .PP This method is used to select the particular sections and subsections of \&\s-1POD\s0 documentation that are to be printed and/or processed. The existing set of selected sections is \fIreplaced\fR with the given set of sections. See \fB\fBadd_selection()\fB\fR for adding to the current set of selected sections. .PP Each of the \f(CW$section_spec\fR arguments should be a section specification as described in \*(L"\s-1SECTION SPECIFICATIONS\*(R"\s0. The section specifications are parsed by this method and the resulting regular expressions are stored in the invoking object. .PP If no \f(CW$section_spec\fR arguments are given, then the existing set of selected sections is cleared out (which means \f(CW\*(C`all\*(C'\fR sections will be processed). .PP This method should \fInot\fR normally be overridden by subclasses. .SH "\fBadd_selection()\fP" .IX Header "add_selection()" .Vb 1 \& $parser\->add_selection($section_spec1,$section_spec2,...); .Ve .PP This method is used to add to the currently selected sections and subsections of \s-1POD\s0 documentation that are to be printed and/or processed. See <\fBselect()\fR> for replacing the currently selected sections. .PP Each of the \f(CW$section_spec\fR arguments should be a section specification as described in \*(L"\s-1SECTION SPECIFICATIONS\*(R"\s0. The section specifications are parsed by this method and the resulting regular expressions are stored in the invoking object. .PP This method should \fInot\fR normally be overridden by subclasses. .SH "\fBclear_selections()\fP" .IX Header "clear_selections()" .Vb 1 \& $parser\->clear_selections(); .Ve .PP This method takes no arguments, it has the exact same effect as invoking <\fBselect()\fR> with no arguments. .SH "\fBmatch_section()\fP" .IX Header "match_section()" .Vb 1 \& $boolean = $parser\->match_section($heading1,$heading2,...); .Ve .PP Returns a value of true if the given section and subsection heading titles match any of the currently selected section specifications in effect from prior calls to \fB\fBselect()\fB\fR and \fB\fBadd_selection()\fB\fR (or if there are no explicitly selected/deselected sections). .PP The arguments \f(CW$heading1\fR, \f(CW$heading2\fR, etc. are the heading titles of the corresponding sections, subsections, etc. to try and match. If \&\f(CW$headingN\fR is omitted then it defaults to the current corresponding section heading title in the input. .PP This method should \fInot\fR normally be overridden by subclasses. .SH "\fBis_selected()\fP" .IX Header "is_selected()" .Vb 1 \& $boolean = $parser\->is_selected($paragraph); .Ve .PP This method is used to determine if the block of text given in \&\f(CW$paragraph\fR falls within the currently selected set of \s-1POD\s0 sections and subsections to be printed or processed. This method is also responsible for keeping track of the current input section and subsections. It is assumed that \f(CW$paragraph\fR is the most recently read (but not yet processed) input paragraph. .PP The value returned will be true if the \f(CW$paragraph\fR and the rest of the text in the same section as \f(CW$paragraph\fR should be selected (included) for processing; otherwise a false value is returned. .SH "EXPORTED FUNCTIONS" .IX Header "EXPORTED FUNCTIONS" The following functions are exported by this module. Please note that these are functions (not methods) and therefore \f(CW\*(C`do not\*(C'\fR take an implicit first argument. .SH "\fBpodselect()\fP" .IX Header "podselect()" .Vb 1 \& podselect(\e%options,@filelist); .Ve .PP \&\fBpodselect\fR will print the raw (untranslated) \s-1POD\s0 paragraphs of all \&\s-1POD\s0 sections in the given input files specified by \f(CW@filelist\fR according to the options given in \f(CW\*(C`\e%options\*(C'\fR. .PP If any argument to \fBpodselect\fR is a reference to a hash (associative array) then the values with the following keys are processed as follows: .IP "\fB\-output\fR" 4 .IX Item "-output" A string corresponding to the desired output file (or \*(L">&STDOUT\*(R" or \*(L">&STDERR\*(R"), or a filehandle to write on. The default is to use standard output. .IP "\fB\-sections\fR" 4 .IX Item "-sections" A reference to an array of sections specifications (as described in \&\*(L"\s-1SECTION SPECIFICATIONS\*(R"\s0) which indicate the desired set of \s-1POD\s0 sections and subsections to be selected from input. If no section specifications are given, then all sections of the PODs are used. .PP All other arguments are optional and should correspond to filehandles to read from or the names of input files containing \s-1POD\s0 sections. A file name of "\*(L", \*(R"\-\*(L" or \*(R"<&STDIN" will be interpreted to mean standard input (which is the default if no arguments are given). .SH "PRIVATE METHODS AND DATA" .IX Header "PRIVATE METHODS AND DATA" \&\fBPod::Select\fR makes uses a number of internal methods and data fields which clients should not need to see or use. For the sake of avoiding name collisions with client data and methods, these methods and fields are briefly discussed here. Determined hackers may obtain further information about them by reading the \fBPod::Select\fR source code. .PP Private data fields are stored in the hash-object whose reference is returned by the \fB\fBnew()\fB\fR constructor for this class. The names of all private methods and data-fields used by \fBPod::Select\fR begin with a prefix of \*(L"_\*(R" and match the regular expression \f(CW\*(C`/^_\ew+$/\*(C'\fR. .SH "SEE ALSO" .IX Header "SEE ALSO" Pod::Parser .SH "AUTHOR" .IX Header "AUTHOR" Please report bugs using . .PP Brad Appleton .PP Based on code for \fBpod2text\fR written by Tom Christiansen .PP \&\fBPod::Select\fR is part of the Pod::Parser distribution.