Pod::InputObjects(3)
β¨ NAME β¨
okay bestie, welcome to Pod::InputObjects(3) from User Contributed Perl Documentation π this page is literally about Pod::InputObjects β objects representing POD input paragraphs, commands, etc. π
πΈ SYNOPSIS πΈ
the whole mood is one line:
use Pod::InputObjects;
π¦ REQUIRES π¦
perl5.004, Carp β that's the whole guest list, no cap.
π EXPORTS π
Nothing. literally zero exports, bestie. nothing is getting handed out here π
π₯ DESCRIPTION π₯
NOTE: This module is considered legacy; modern Perl releases (5.31.1and higher) are going to remove Pod-Parser from core and usePod::Simplefor all things POD. π
This module defines some basic input objects used by Pod::Parser when reading and parsing POD text from an input source. The following objects are defined:
package Pod::Paragraphβ an object corresponding to a paragraph of POD input text. It may be a plain paragraph, a verbatim paragraph, or a command paragraph (seeperlpod). πpackage Pod::InteriorSequenceβ an object corresponding to an interior sequence command from the POD input text (seeperlpod). π¦package Pod::ParseTreeβ an object corresponding to a tree of parsed POD text. Each "node" in a parse-tree (or ptree) is either a text-string or a reference to aPod::InteriorSequenceobject. The nodes appear in the parse-tree in the order in which they were parsed from left-to-right. π
Each of these input objects are described in further detail in the sections which follow. bestie, there's lore. keep reading π
π Pod::Paragraph π
An object representing a paragraph of POD input text. It has the following methods/attributes:
π Pod::Paragraph->new() π
my $pod_para1 = Pod::Paragraph->new(-text => $text);
my $pod_para2 = Pod::Paragraph->new(-name => $cmd,
-text => $text);
my $pod_para3 = new Pod::Paragraph(-text => $text);
my $pod_para4 = new Pod::Paragraph(-name => $cmd,
-text => $text);
my $pod_para5 = Pod::Paragraph->new(-name => $cmd,
-text => $text,
-file => $filename,
-line => $line_number);
This is a class method that constructs a Pod::Paragraph object and returns a reference to the new paragraph object. It may be given one or two keyword arguments. The -text keyword indicates the corresponding text of the POD paragraph. The -name keyword indicates the name of the corresponding POD command, such as head1 or item (it should not contain the = prefix); this is needed only if the POD paragraph corresponds to a command paragraph. The -file and -line keywords indicate the filename and line number corresponding to the beginning of the paragraph β¨
π«Ά $pod_para->cmd_name() π«Ά
my $para_cmd = $pod_para->cmd_name();
If this paragraph is a command paragraph, then this method will return the name of the command (without any leading = prefix). slay π
πΈ $pod_para->text() πΈ
my $para_text = $pod_para->text();
This method will return the corresponding text of the paragraph. that's it, that's the tea π
π¦ $pod_para->raw_text() π¦
my $raw_pod_para = $pod_para->raw_text();
This method will return the raw text of the POD paragraph, exactly as it appeared in the input. no edits, no filter, raw raw π«Ά
π $pod_para->cmd_prefix() π
my $prefix = $pod_para->cmd_prefix();
If this paragraph is a command paragraph, then this method will return the prefix used to denote the command (which should be the string = or ==). periodt π
β $pod_para->cmd_separator() β
my $separator = $pod_para->cmd_separator();
If this paragraph is a command paragraph, then this method will return the text used to separate the command name from the rest of the paragraph (if any). cute little divider vibes π«
π $pod_para->parse_tree() π
my $ptree = $pod_parser->parse_text( $pod_para->text() );
$pod_para->parse_tree( $ptree );
$ptree = $pod_para->parse_tree();
This method will get/set the corresponding parse-tree of the paragraph's text. get it, set it, own it π
π $pod_para->file_line() π
my ($filename, $line_number) = $pod_para->file_line();
my $position = $pod_para->file_line();
Returns the current filename and line number for the paragraph 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. iykyk π§
π Pod::InteriorSequence π
An object representing a POD interior sequence command. It has the following methods/attributes:
π Pod::InteriorSequence->new() π
my $pod_seq1 = Pod::InteriorSequence->new(-name => $cmd
-ldelim => $delimiter);
my $pod_seq2 = new Pod::InteriorSequence(-name => $cmd,
-ldelim => $delimiter);
my $pod_seq3 = new Pod::InteriorSequence(-name => $cmd,
-ldelim => $delimiter,
-file => $filename,
-line => $line_number);
my $pod_seq4 = new Pod::InteriorSequence(-name => $cmd, $ptree);
my $pod_seq5 = new Pod::InteriorSequence($cmd, $ptree);
This is a class method that constructs a Pod::InteriorSequence object and returns a reference to the new interior sequence object. It should be given two keyword arguments. The -ldelim keyword indicates the corresponding left-delimiter of the interior sequence (e.g. <). The -name keyword indicates the name of the corresponding interior sequence command, such as I or B or C. The -file and -line keywords indicate the filename and line number corresponding to the beginning of the interior sequence. If the $ptree argument is given, it must be the last argument, and it must be either string, or else an array-ref suitable for passing to Pod::ParseTree::new (or it may be a reference to a Pod::ParseTree object). bestie read that twice, it matters π
π«Ά $pod_seq->cmd_name() π«Ά
my $seq_cmd = $pod_seq->cmd_name();
The name of the interior sequence command. simple, iconic, no notes β¨
π¦ $pod_seq->prepend() π¦
$pod_seq->prepend($text);
$pod_seq1->prepend($pod_seq2);
Prepends the given string or parse-tree or sequence object to the parse-tree of this interior sequence. put it at the front, main character energy π
πΈ $pod_seq->append() πΈ
$pod_seq->append($text);
$pod_seq1->append($pod_seq2);
Appends the given string or parse-tree or sequence object to the parse-tree of this interior sequence. same energy, opposite end π
β $pod_seq->nested() β
$outer_seq = $pod_seq->nested || print "not nested";
If this interior sequence is nested inside of another interior sequence, then the outer/parent sequence that contains it is returned. Otherwise undef is returned. who's your parent? found family arc π₯
π $pod_seq->raw_text() π
my $seq_raw_text = $pod_seq->raw_text();
This method will return the raw text of the POD interior sequence, exactly as it appeared in the input. no glam filter, just facts π
π $pod_seq->left_delimiter() π
my $ldelim = $pod_seq->left_delimiter();
The leftmost delimiter beginning the argument text to the interior sequence (should be <). left side represent π
π $pod_seq->right_delimiter() π
The rightmost delimiter beginning the argument text to the interior sequence (should be >). right side represent β¨
π«Ά $pod_seq->parse_tree() π«Ά
my $ptree = $pod_parser->parse_text($paragraph_text);
$pod_seq->parse_tree( $ptree );
$ptree = $pod_seq->parse_tree();
This method will get/set the corresponding parse-tree of the interior sequence's text. get/set queen behavior π
π $pod_seq->file_line() π
my ($filename, $line_number) = $pod_seq->file_line();
my $position = $pod_seq->file_line();
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. same rule, different object, bestie π§
π Pod::InteriorSequence::DESTROY() π
This method performs any necessary cleanup for the interior-sequence. If you override this method then it is imperative that you invoke the parent method from within your own method, otherwise interior-sequence storage will not be reclaimed upon destruction!
bestie this is the important warning era: override it if you must, but call the parent method or the storage will not be reclaimed upon destruction. not me forgetting the parent call π
β¦okay but we're only halfway through the lore β part 2 has the rest, so stay tuned π
π¦ Pod::ParseTree π¦
okay so this object? It's giving the entire tree of parsed POD text, literally. As POD text gets scanned from left to right, it's parsed into an ordered list of text-strings and Pod::InteriorSequence objects (in order of appearance, bestie). A Pod::ParseTree object corresponds to this list of strings and sequences. And plot twist: each interior sequence in the parse-tree may itself contain a parse-tree (because interior sequences can be nested, slay). π«Ά
β¨ Pod::ParseTree->new() β¨
my $ptree1 = Pod::ParseTree->new;
my $ptree2 = new Pod::ParseTree;
my $ptree4 = Pod::ParseTree->new($array_ref);
my $ptree3 = new Pod::ParseTree($array_ref);
This is a class method that constructs a "Pod::Parse_tree" 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. No cap, that's the whole vibe. π
πΈ $ptree->top() πΈ
my $top_node = $ptree->top();
$ptree->top( $top_node );
$ptree->top( @children );
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 Pod::ParseTree. If it is given a single argument that is a reference, then the reference is assumed to be 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. π
π $ptree->children() π
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 Pod::InteriorSequence. Otherwise, if arguments are given, they are treated as the new list of children for the top node. π
π $ptree->prepend() π
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 before the current one. π
π $ptree->append() π
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 after the current one. π
β $ptree->raw_text() β
my $ptree_raw_text = $ptree->raw_text();
This method will return the raw text of the POD parse-tree exactly as it appeared in the input. Iconic. β¨
π
Pod::ParseTree::DESTROY() π
This method performs any necessary cleanup for the parse-tree. If you override this method then it is imperative that you invoke the parent method from within your own method, otherwise parse-tree storage will not be reclaimed upon destruction! π Like, do not forget the parent call, seriously.
π SEE ALSO π
Pod::InputObjects is part of the Pod::Parser distribution.
See Pod::Parser, Pod::Select.
π AUTHOR π
Please report bugs using <http://rt.cpan.org>.
Brad Appleton <bradapp@enteract.com>
That's the whole vibe β source/version perl v5.40.0, dated 2024-10-29, page Pod::InputObjects(3). Bye bestie, go parse something cute! πβ¨
π¦ where this page comes from
- centos-stream 10: perl-Pod-Parser 1.67-5.el10 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms