Config::HAProxy::Iterator - Iterate over objects in the parse tree
$cfg = Config::HAProxy->new->parse; $itr = $cfg->iterator(inorder => 1); while (defined(my $node = $itr->next)) { # Do something with $node }
The iterator object provides a method for iterating over all nodes in the HAProxy parse tree. The object is returned by the iterator method of Config::HAProxy and Config::HAProxy::Node objects. The method takes as optional argument the keyword specifying the order in which the tree nodes should be traversed. This keyword can be one of the following:
No recursion. The traversal will not descend into section nodes. This is the default.
The nodes will be traversed in the inorder manner, i.e. the section node will be visited first, and all its sub-nodes after it.
The nodes will be traversed in the postorder manner, i.e. for each section node, its sub-nodes will be visited first, and the node itself afterward.
Note: This section is informative. You never need to create Config::HAProxy::Iterator objects explicitly. Please use the iterator method of Config::HAProxy or Config::HAProxy::Node class objects.
$itr = new Config::HAProxy::Iterator($node, %rec);
Returns new iterator object for traversing the tree starting from $node, which must be a Config::HAProxy::Node object. Optional %rec is one of the keywords discussed above, in section DESCRIPTION.
$node = $itr->next;
Returns next node in the traversal sequence. If all nodes were visited, returns undef.
HAProxy::Config, HAProxy::Config::Node.
To install Config::HAProxy, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Config::HAProxy
CPAN shell
perl -MCPAN -e shell install Config::HAProxy
For more information on module installation, please visit the detailed CPAN module installation guide.