inputobjects.html
来自「perl教程」· HTML 代码 · 共 444 行 · 第 1/3 页
HTML
444 行
<pre>
<span class="variable">$outer_seq</span> <span class="operator">=</span> <span class="variable">$pod_seq</span><span class="operator">-></span><span class="variable">nested</span> <span class="operator">||</span> <span class="keyword">print</span> <span class="string">"not nested"</span><span class="operator">;</span>
</pre>
<p>If this interior sequence is nested inside of another interior
sequence, then the outer/parent sequence that contains it is
returned. Otherwise <a href="../../lib/Pod/perlfunc.html#item_undef"><code>undef</code></a> is returned.</p>
<p>
</p>
<h2><a name="_pod_seq_raw_text__">$pod_seq-><strong>raw_text()</strong></a></h2>
<pre>
<span class="keyword">my</span> <span class="variable">$seq_raw_text</span> <span class="operator">=</span> <span class="variable">$pod_seq</span><span class="operator">-></span><span class="variable">raw_text</span><span class="operator">();</span>
</pre>
<p>This method will return the <em>raw</em> text of the POD interior sequence,
exactly as it appeared in the input.</p>
<p>
</p>
<h2><a name="_pod_seq_left_delimiter__">$pod_seq-><strong>left_delimiter()</strong></a></h2>
<pre>
<span class="keyword">my</span> <span class="variable">$ldelim</span> <span class="operator">=</span> <span class="variable">$pod_seq</span><span class="operator">-></span><span class="variable">left_delimiter</span><span class="operator">();</span>
</pre>
<p>The leftmost delimiter beginning the argument text to the interior
sequence (should be "<").</p>
<p>
</p>
<h2><a name="_pod_seq_right_delimiter__">$pod_seq-><strong>right_delimiter()</strong></a></h2>
<p>The rightmost delimiter beginning the argument text to the interior
sequence (should be ">").</p>
<p>
</p>
<h2><a name="_pod_seq_parse_tree__">$pod_seq-><strong>parse_tree()</strong></a></h2>
<pre>
<span class="keyword">my</span> <span class="variable">$ptree</span> <span class="operator">=</span> <span class="variable">$pod_parser</span><span class="operator">-></span><span class="variable">parse_text</span><span class="operator">(</span><span class="variable">$paragraph_text</span><span class="operator">);</span>
<span class="variable">$pod_seq</span><span class="operator">-></span><span class="variable">parse_tree</span><span class="operator">(</span> <span class="variable">$ptree</span> <span class="operator">);</span>
<span class="variable">$ptree</span> <span class="operator">=</span> <span class="variable">$pod_seq</span><span class="operator">-></span><span class="variable">parse_tree</span><span class="operator">();</span>
</pre>
<p>This method will get/set the corresponding parse-tree of the interior
sequence's text.</p>
<p>
</p>
<h2><a name="_pod_seq_file_line__">$pod_seq-><strong>file_line()</strong></a></h2>
<pre>
<span class="keyword">my</span> <span class="operator">(</span><span class="variable">$filename</span><span class="operator">,</span> <span class="variable">$line_number</span><span class="operator">)</span> <span class="operator">=</span> <span class="variable">$pod_seq</span><span class="operator">-></span><span class="variable">file_line</span><span class="operator">();</span>
<span class="keyword">my</span> <span class="variable">$position</span> <span class="operator">=</span> <span class="variable">$pod_seq</span><span class="operator">-></span><span class="variable">file_line</span><span class="operator">();</span>
</pre>
<p>Returns the current filename and line number for the interior sequence
object. If called in a list context, it returns a list of two
elements: first the filename, then the line number. If called in
a scalar context, it returns a string containing the filename, followed
by a colon (':'), followed by the line number.</p>
<p>
</p>
<h2><a name="pod__interiorsequence__destroy__">Pod::InteriorSequence::<strong>DESTROY()</strong></a></h2>
<p>This method performs any necessary cleanup for the interior-sequence.
If you override this method then it is <strong>imperative</strong> that you invoke
the parent method from within your own method, otherwise
<em>interior-sequence storage will not be reclaimed upon destruction!</em></p>
<p>
</p>
<hr />
<h1><a name="pod__parsetree"><strong>Pod::ParseTree</strong></a></h1>
<p>This object corresponds to a tree of parsed POD text. As POD text is
scanned from left to right, it is parsed into an ordered list of
text-strings and <strong>Pod::InteriorSequence</strong> objects (in order of
appearance). A <strong>Pod::ParseTree</strong> object corresponds to this list of
strings and sequences. Each interior sequence in the parse-tree may
itself contain a parse-tree (since interior sequences may be nested).</p>
<p>
</p>
<h2><a name="pod__parsetree_new__">Pod::ParseTree-><strong>new()</strong></a></h2>
<pre>
<span class="keyword">my</span> <span class="variable">$ptree1</span> <span class="operator">=</span> <span class="variable">Pod::ParseTree</span><span class="operator">-></span><span class="variable">new</span><span class="operator">;</span>
<span class="keyword">my</span> <span class="variable">$ptree2</span> <span class="operator">=</span> <span class="variable">new</span> <span class="variable">Pod::ParseTree</span><span class="operator">;</span>
<span class="keyword">my</span> <span class="variable">$ptree4</span> <span class="operator">=</span> <span class="variable">Pod::ParseTree</span><span class="operator">-></span><span class="variable">new</span><span class="operator">(</span><span class="variable">$array_ref</span><span class="operator">);</span>
<span class="keyword">my</span> <span class="variable">$ptree3</span> <span class="operator">=</span> <span class="variable">new</span> <span class="variable">Pod::ParseTree</span><span class="operator">(</span><span class="variable">$array_ref</span><span class="operator">);</span>
</pre>
<p>This is a class method that constructs a <code>Pod::Parse_tree</code> object and
returns a reference to the new parse-tree. If a single-argument is given,
it must be a reference to an array, and is used to initialize the root
(top) of the parse tree.</p>
<p>
</p>
<h2><a name="_ptree_top__">$ptree-><strong>top()</strong></a></h2>
<pre>
<span class="keyword">my</span> <span class="variable">$top_node</span> <span class="operator">=</span> <span class="variable">$ptree</span><span class="operator">-></span><span class="variable">top</span><span class="operator">();</span>
<span class="variable">$ptree</span><span class="operator">-></span><span class="variable">top</span><span class="operator">(</span> <span class="variable">$top_node</span> <span class="operator">);</span>
<span class="variable">$ptree</span><span class="operator">-></span><span class="variable">top</span><span class="operator">(</span> <span class="variable">@children</span> <span class="operator">);</span>
</pre>
<p>This method gets/sets the top node of the parse-tree. If no arguments are
given, it returns the topmost node in the tree (the root), which is also
a <strong>Pod::ParseTree</strong>. If it is given a single argument that is a reference,
then the reference is assumed to a parse-tree and becomes the new top node.
Otherwise, if arguments are given, they are treated as the new list of
children for the top node.</p>
<p>
</p>
<h2><a name="_ptree_children__">$ptree-><strong>children()</strong></a></h2>
<p>This method gets/sets the children of the top node in the parse-tree.
If no arguments are given, it returns the list (array) of children
(each of which should be either a string or a <strong>Pod::InteriorSequence</strong>.
Otherwise, if arguments are given, they are treated as the new list of
children for the top node.</p>
<p>
</p>
<h2><a name="_ptree_prepend__">$ptree-><strong>prepend()</strong></a></h2>
<p>This method prepends the given text or parse-tree to the current parse-tree.
If the first item on the parse-tree is text and the argument is also text,
then the text is prepended to the first item (not added as a separate string).
Otherwise the argument is added as a new string or parse-tree <em>before</em>
the current one.</p>
<p>
</p>
<h2><a name="_ptree_append__">$ptree-><strong>append()</strong></a></h2>
<p>This method appends the given text or parse-tree to the current parse-tree.
If the last item on the parse-tree is text and the argument is also text,
then the text is appended to the last item (not added as a separate string).
Otherwise the argument is added as a new string or parse-tree <em>after</em>
the current one.</p>
<p>
</p>
<h2><a name="_ptree_raw_text__">$ptree-><strong>raw_text()</strong></a></h2>
<pre>
<span class="keyword">my</span> <span class="variable">$ptree_raw_text</span> <span class="operator">=</span> <span class="variable">$ptree</span><span class="operator">-></span><span class="variable">raw_text</span><span class="operator">();</span>
</pre>
<p>This method will return the <em>raw</em> text of the POD parse-tree
exactly as it appeared in the input.</p>
<p>
</p>
<h2><a name="pod__parsetree__destroy__">Pod::ParseTree::<strong>DESTROY()</strong></a></h2>
<p>This method performs any necessary cleanup for the parse-tree.
If you override this method then it is <strong>imperative</strong>
that you invoke the parent method from within your own method,
otherwise <em>parse-tree storage will not be reclaimed upon destruction!</em></p>
<p>
</p>
<hr />
<h1><a name="see_also">SEE ALSO</a></h1>
<p>See <a href="../../lib/Pod/Parser.html">the Pod::Parser manpage</a>, <a href="../../lib/Pod/Select.html">the Pod::Select 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>
</body>
</html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?