select.html
来自「perl教程」· HTML 代码 · 共 353 行 · 第 1/2 页
HTML
353 行
</li>
<li>
<p>Match all top level sections but none of their subsections:</p>
<p><code>/!.+</code></p>
</li>
</ul>
<p>
</p>
<hr />
<h1><a name="object_methods">OBJECT METHODS</a></h1>
<p>The following methods are provided in this module. Each one takes a
reference to the object itself as an implicit first parameter.</p>
<p>
</p>
<hr />
<h1><a name="curr_headings__"><strong>curr_headings()</strong></a></h1>
<pre>
<span class="operator">(</span><span class="variable">$head1</span><span class="operator">,</span> <span class="variable">$head2</span><span class="operator">,</span> <span class="variable">$head3</span><span class="operator">,</span> <span class="operator">...)</span> <span class="operator">=</span> <span class="variable">$parser</span><span class="operator">-></span><span class="variable">curr_headings</span><span class="operator">();</span>
<span class="variable">$head1</span> <span class="operator">=</span> <span class="variable">$parser</span><span class="operator">-></span><span class="variable">curr_headings</span><span class="operator">(</span><span class="number">1</span><span class="operator">);</span>
</pre>
<p>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.</p>
<p>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 <a href="../../lib/Pod/perlfunc.html#item_undef"><code>undef</code></a> is returned.</p>
<p>
</p>
<hr />
<h1><a name="select__"><strong>select()</strong></a></h1>
<pre>
<span class="variable">$parser</span><span class="operator">-></span><span class="keyword">select</span><span class="operator">(</span><span class="variable">$section_spec1</span><span class="operator">,</span><span class="variable">$section_spec2</span><span class="operator">,...);</span>
</pre>
<p>This method is used to select the particular sections and subsections of
POD documentation that are to be printed and/or processed. The existing
set of selected sections is <em>replaced</em> with the given set of sections.
See <strong>add_selection()</strong> for adding to the current set of selected
sections.</p>
<p>Each of the <code>$section_spec</code> arguments should be a section specification
as described in <a href="#section_specifications">SECTION SPECIFICATIONS</a>. The section specifications
are parsed by this method and the resulting regular expressions are
stored in the invoking object.</p>
<p>If no <code>$section_spec</code> arguments are given, then the existing set of
selected sections is cleared out (which means <code>all</code> sections will be
processed).</p>
<p>This method should <em>not</em> normally be overridden by subclasses.</p>
<p>
</p>
<hr />
<h1><a name="add_selection__"><strong>add_selection()</strong></a></h1>
<pre>
<span class="variable">$parser</span><span class="operator">-></span><span class="variable">add_selection</span><span class="operator">(</span><span class="variable">$section_spec1</span><span class="operator">,</span><span class="variable">$section_spec2</span><span class="operator">,...);</span>
</pre>
<p>This method is used to add to the currently selected sections and
subsections of POD documentation that are to be printed and/or
processed. See <select()> for replacing the currently selected sections.</p>
<p>Each of the <code>$section_spec</code> arguments should be a section specification
as described in <a href="#section_specifications">SECTION SPECIFICATIONS</a>. The section specifications
are parsed by this method and the resulting regular expressions are
stored in the invoking object.</p>
<p>This method should <em>not</em> normally be overridden by subclasses.</p>
<p>
</p>
<hr />
<h1><a name="clear_selections__"><strong>clear_selections()</strong></a></h1>
<pre>
<span class="variable">$parser</span><span class="operator">-></span><span class="variable">clear_selections</span><span class="operator">();</span>
</pre>
<p>This method takes no arguments, it has the exact same effect as invoking
<select()> with no arguments.</p>
<p>
</p>
<hr />
<h1><a name="match_section__"><strong>match_section()</strong></a></h1>
<pre>
<span class="variable">$boolean</span> <span class="operator">=</span> <span class="variable">$parser</span><span class="operator">-></span><span class="variable">match_section</span><span class="operator">(</span><span class="variable">$heading1</span><span class="operator">,</span><span class="variable">$heading2</span><span class="operator">,...);</span>
</pre>
<p>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 <strong>select()</strong> and <strong>add_selection()</strong> (or if
there are no explictly selected/deselected sections).</p>
<p>The arguments <code>$heading1</code>, <code>$heading2</code>, etc. are the heading titles of
the corresponding sections, subsections, etc. to try and match. If
<code>$headingN</code> is omitted then it defaults to the current corresponding
section heading title in the input.</p>
<p>This method should <em>not</em> normally be overridden by subclasses.</p>
<p>
</p>
<hr />
<h1><a name="is_selected__"><strong>is_selected()</strong></a></h1>
<pre>
<span class="variable">$boolean</span> <span class="operator">=</span> <span class="variable">$parser</span><span class="operator">-></span><span class="variable">is_selected</span><span class="operator">(</span><span class="variable">$paragraph</span><span class="operator">);</span>
</pre>
<p>This method is used to determine if the block of text given in
<code>$paragraph</code> falls within the currently selected set of POD 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 <code>$paragraph</code> is the most recently read
(but not yet processed) input paragraph.</p>
<p>The value returned will be true if the <code>$paragraph</code> and the rest of the
text in the same section as <code>$paragraph</code> should be selected (included)
for processing; otherwise a false value is returned.</p>
<p>
</p>
<hr />
<h1><a name="exported_functions">EXPORTED FUNCTIONS</a></h1>
<p>The following functions are exported by this module. Please note that
these are functions (not methods) and therefore <code>do not</code> take an
implicit first argument.</p>
<p>
</p>
<hr />
<h1><a name="podselect__"><strong>podselect()</strong></a></h1>
<pre>
<span class="variable">podselect</span><span class="operator">(\</span><span class="variable">%options</span><span class="operator">,</span><span class="variable">@filelist</span><span class="operator">);</span>
</pre>
<p><strong>podselect</strong> will print the raw (untranslated) POD paragraphs of all
POD sections in the given input files specified by <code>@filelist</code>
according to the given options.</p>
<p>If any argument to <strong>podselect</strong> is a reference to a hash
(associative array) then the values with the following keys are
processed as follows:</p>
<dl>
<dt><strong><a name="item__2doutput"><strong>-output</strong></a></strong>
<dd>
<p>A string corresponding to the desired output file (or ">&STDOUT"
or ">&STDERR"). The default is to use standard output.</p>
</dd>
</li>
<dt><strong><a name="item__2dsections"><strong>-sections</strong></a></strong>
<dd>
<p>A reference to an array of sections specifications (as described in
<a href="#section_specifications">SECTION SPECIFICATIONS</a>) which indicate the desired set of POD
sections and subsections to be selected from input. If no section
specifications are given, then all sections of the PODs are used.</p>
</dd>
</li>
</dl>
<p>All other arguments should correspond to the names of input files
containing POD sections. A file name of "-" or "<&STDIN" will
be interpeted to mean standard input (which is the default if no
filenames are given).</p>
<p>
</p>
<hr />
<h1><a name="private_methods_and_data">PRIVATE METHODS AND DATA</a></h1>
<p><strong>Pod::Select</strong> 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 <strong>Pod::Select</strong> source code.</p>
<p>Private data fields are stored in the hash-object whose reference is
returned by the <strong>new()</strong> constructor for this class. The names of all
private methods and data-fields used by <strong>Pod::Select</strong> begin with a
prefix of "_" and match the regular expression <code>/^_\w+$/</code>.</p>
<p>
</p>
<hr />
<h1><a name="see_also">SEE ALSO</a></h1>
<p><a href="../../lib/Pod/Parser.html">the Pod::Parser manpage</a></p>
<p>
</p>
<hr />
<h1><a name="author">AUTHOR</a></h1>
<p>Please report bugs using <a href="http://rt.cpan.org">http://rt.cpan.org</a>.</p>
<p>Brad Appleton <<a href="mailto:bradapp@enteract.com">bradapp@enteract.com</a>></p>
<p>Based on code for <strong>pod2text</strong> written by
Tom Christiansen <<a href="mailto:tchrist@mox.perl.com">tchrist@mox.perl.com</a>></p>
</body>
</html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?