PPIx::Regexp::Node(3)
π PPIx::Regexp::Node π
okay bestie, welcome to the PPIx::Regexp::Node page β this is the User Contributed Perl Documentation version, and it's giving "container class that holds all the other classes". let's get into it π«Ά
β¨ NAME β¨
PPIx::Regexp::Node β Represent a container. that's it, that's the whole job, she's a box π
πΈ SYNOPSIS πΈ
use PPIx::Regexp::Dumper;
PPIx::Regexp::Dumper->new( 'qr{(foo)}' )->print();
π¦ INHERITANCE π¦
so like, <pink>PPIx::Regexp::Node</pink> is a PPIx::Regexp::Element. family tree moment β¨
and she's the parent of PPIx::Regexp, PPIx::Regexp::Node::Range and PPIx::Regexp::Structure. so yeah, she's the mother of the whole lil friend group π
π DESCRIPTION π
this class represents a structural element that contains other classes. it's an abstract class, meaning the lexer does not instantiate it. she's not out here getting built directly, she's just the blueprint. very main character energy, never actually on screen π
π METHODS π
this class provides the following public methods. the ones that aren't documented here are private, and unsupported in the sense that the author reserves the right to change or remove them without notice. so like, don't get attached to the undocumented ones, they could ghost you at any time π
π child
my $kid = $node->child( 0 );
this method returns the child at the given index. indices start from zero, and negative indices count from the end of the list, so $node->child( -1 ) hands you the last child of the node. yes bestie, she supports negative indexing, we love a flexible queen π
β¨ children
this method returns the children of the Node. and ooh, if you call it in scalar context, it returns the number of children instead. context-sensitive behavior, we love to see it π
π¦ contains
print $node->contains( $elem ) ? "yes\n" : "no\n";
returns true if the given element is contained in the node, false otherwise. simple, clean, no cap π
πΈ elements
this method returns the elements in the Node. for a PPIx::Regexp::Node proper, it's the same as children(). same vibe, different name π
π₯ find
my $rslt = $node->find( 'PPIx::Regexp::Token::Literal' );
my $rslt = $node->find( 'Token::Literal' );
my $rslt = $node->find( sub {
return $_[1]->isa( 'PPIx::Regexp::Token::Literal' )
&& $_[1]->ordinal < ord(' ');
} );
this method finds things. (iconic description, no notes π)
here's the tea on the arguments:
- if you give it a string, it's assumed to be a class name (possibly without the leading
'PPIx::Regexp::'), and all elements of that class get found. - if you give it a code reference, that code reference gets called once for each element, and it's passed
$selfand the element. your code should return:- true to accept the element,
- false to reject it,
- and (for subclasses of
PPIx::Regexp::Node)undefto prevent recursion into the node.
and heads up β if the code throws an exception, you get nothing back from this method. π
either way, the return is a reference to the list of things found, a false (but defined) value if nothing was found, or undef if an error occurred. note that "false but defined" vs "undef" distinction, she's subtle like that π§
π find_parents
my $rslt = $node->find_parents( sub {
return $_[1]->isa( 'PPIx::Regexp::Token::Operator' )
&& $_[1]->content() eq '|';
} );
this convenience method takes the same arguments as find, but instead of the found objects themselves, it returns their parents. and no parent will appear more than once in the output β no duplicates here, we're not about that messy life π
returns a reference to the array of parents if any were found. if no parents were found, the return is false but defined. if an error occurred, the return is undef.
β find_first
this method has the same arguments as find, but returns either a reference to the first element found, a false (but defined) value if no elements were found, or undef if an error occurred. first come, first served π
π first_element
this method returns the first element in the node.
π first_token
this method returns the first token in the node. if there is none, it returns nothing. (silence, she just doesn't answer, we've all been there π)
π¦ last_element
this method returns the last element in the node.
π last_token
this method returns the last token in the node. if there is none, it returns nothing.
β¨ is_matcher
this method returns a true value if any of the node's children does. otherwise it returns undef if any of the node's children does. otherwise it returns a false (but defined) value. yeah bestie, that's literally what it says β three-way answer, we love a nuanced response π
πΈ perl_version_introduced
this method returns the maximum value of perl_version_introduced returned by any of its elements. in other words, it returns the minimum version of Perl under which this node is valid. if there are no elements, 5.000 is returned, since that's the minimum value of Perl supported by this package. tiny number, big responsibility π
π₯ perl_version_removed
this method returns the minimum defined value of perl_version_removed returned by any of the node's elements. in other words, it returns the lowest version of Perl in which this node is not valid. if there are no elements, or if no element has a defined perl_version_removed, undef is returned.
π§ schild
this method returns the significant child at the given index; that is, $node->schild(0) returns the first significant child, $node->schild(1) returns the second significant child, and so on. negative indices count from the end. the "s" stands for significant, and also for slay π
π schildren
this method returns the significant children of the Node. if called in scalar context, it returns the number of significant children. (yes, same context trick as children β the family has patterns π)
π«Ά SUPPORT π«Ά
support is by the author. please file bug reports at <https://github.com/trwyant/perl-PPIx-Regexp/issues> or in electronic mail to the author. found a bug? tell her, don't just suffer in silence bestie π
π AUTHOR π
Thomas R. Wyant, III β harryfmudd at comcast dot net
π COPYRIGHT AND LICENSE π
Copyright (C) 2009-2023, 2025-2026 by Thomas R. Wyant, III
this program is free software; you can redistribute it and/or modify it under the same terms as Perl 5.10.0. for more details, see the full text of the licenses in the directory LICENSES.
this program is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose. (so like, she's free, but she's not making any promises, okay? π)
and that's the whole page, bestie!! this was PPIx::Regexp::Node(3) from perl v5.42.2, dated 2026-06-15 β literally the version and date from the footer, folded into this lil sign-off because we're cute like that πβ¨ bye, go write some regexes, ily π
π¦ where this page comes from
- fedora 43: perl-PPIx-Regexp 0.092-1.fc43 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- fedora 44: perl-PPIx-Regexp 0.092-1.fc44 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms