Sergey Poznyakoff

NAME

Config::HAProxy::Iterator - Iterate over objects in the parse tree

SYNOPSIS

    $cfg = Config::HAProxy->new->parse;    
    $itr = $cfg->iterator(inorder => 1);
    while (defined(my $node = $itr->next)) {
        # Do something with $node
    }

DESCRIPTION

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:

recursive => 0

No recursion. The traversal will not descend into section nodes. This is the default.

inorder => 1

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.

postorder => 1

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.

CONSTRUCTOR

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.

METHODS

next

    $node = $itr->next;

Returns next node in the traversal sequence. If all nodes were visited, returns undef.

SEE ALSO

HAProxy::Config, HAProxy::Config::Node.