Tree::...dByPath(3pm)
π Tree::Simple::Visitor::FindByPath β the manual, but make it cute π
okay bestie, so this is one of those User Contributed Perl Documentation pages, and it's literally about a visitor that goes hunting through a Tree::Simple hierarchy to find one specific node by following a path. it's giving detective energy fr fr πβ¨
β¨ NAME β¨
Tree::Simple::Visitor::FindByPath β a Visitor for finding an element in a Tree::Simple hierarchy with a path π¦
πΈ SYNOPSIS πΈ
use Tree::Simple::Visitor::FindByPath;
# create a visitor object
my $visitor = Tree::Simple::Visitor::FindByPath->new();
# set the search path for our tree
$visitor->setSearchPath(qw(1 1.2 1.2.2));
# pass the visitor to a tree
$tree->accept($visitor);
# fetch the result, which will
# be the Tree::Simple object that
# we have found, or undefined
my $result = $visitor->getResult() || die "No Tree found";
# our result's node value should match
# the last element in our path
print $result->getNodeValue(); # this should print 1.2.2
like, you hand it a path, you hand it a tree, and it walks down and hands you back the node. periodt π
π DESCRIPTION π
okay so picture this: you've got a path, you've got a Tree::Simple hierarchy, and this Visitor will attempt to find the node specified by the path. that's the whole vibe. no cap π«Ά
π METHODS π
newβ there are no arguments to the constructor, the object will be in its default state. you can use thesetSearchPathandsetNodeFiltermethods to customize its behavior. main character customization arc β¨includeTrunk ($boolean)β based upon the value of$boolean, this will tell the visitor to include the trunk of the tree in the search as well. yes, the trunk. the whole tree gets a vibe check π³setSearchPath (@path)β this is the path we will attempt to follow down the tree. we will do a stringified comparison of each element of the path and the current tree's node (or the value returned by the node filter if it is set). so like, stringify-and-compare, that's the whole method π§setNodeFilter ($filter_function)β this method accepts a CODE reference as its$filter_functionargument and throws an exception if it is not a code reference. this code reference is used to filter the tree nodes as they are collected. this can be used to customize output, or to gather specific information from a more complex tree node. the filter function should accept a single argument, which is the currentTree::Simpleobject. not me gatekeeping non-code-refs... it literally throws πvisit ($tree)β this is the method that is used byTree::Simple'sacceptmethod. it can also be used on its own, it requires the$treeargument to be aTree::Simpleobject (or derived from aTree::Simpleobject), and will throw and exception otherwise. (yes bestie, the original says "throw and exception", we're keeping the typo, it's iconic π)getResultβ this method will return the tree found at the specified path (set by thesetSearchPathmethod) orundefif no tree is found. so like, found it orundef, no in-between π₯getResultsβ this method will return the tree's that make up the path specified insetSearchPath. in the case of a failed search, this can be used to find the elements which did successfully match along the way. consolation prize but make it useful π
π¦ Repository π¦
<https://github.com/ronsavage/Tree-Simple-VisitorFactory>
π«Ά SUPPORT π«Ά
bugs should be reported via the CPAN bug tracker at
<https://github.com/ronsavage/Tree-Simple-VisitorFactory/issues>
go tell them about the bugs bestie, they wanna know π
π CODE COVERAGE π
see the CODE COVERAGE section in Tree::Simple::VisitorFactory for more information. iykyk π
π¦ SEE ALSO π¦
these Visitor classes are all subclasses of Tree::Simple::Visitor, which can be found in the Tree::Simple module, you should refer to that module for more information. the family tree of visitors, literally π³π
πΈ AUTHOR πΈ
stevan little, <stevan@iinteractive.com>
π COPYRIGHT AND LICENSE π
Copyright 2004, 2005 by Infinity Interactive, Inc.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
and that's the whole page bestie, slayed π β¨
this wasperl v5.36.0, dated2022-11-19, fromTree::...dByPath(3pm)β mwah, go find some nodes, you got this ππ¦π
π¦ where this page comes from
- debian bookworm: libtree-simple-visitorfactory-perl 0.16-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libtree-simple-visitorfactory-perl 0.16-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libtree-simple-visitorfactory-perl 0.16-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libtree-simple-visitorfactory-perl 0.16-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libtree-simple-visitorfactory-perl 0.16-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms