NAME

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

SYNOPSIS

    $cfg = Config::Proxy->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 Proxy parse tree. The object is returned by the iterator method of Config::Proxy and Config::Proxy::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::Proxy::Iterator objects explicitly. Please use the iterator method of Config::Proxy or Config::Proxy::Node class objects.

$itr = new Config::Proxy::Iterator($node, %rec);

Returns new iterator object for traversing the tree starting from $node, which must be a Config::Proxy::Node object or its derivative. 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

Proxy::Config, Proxy::Config::Node, Config::HAProxy, Config::Pound.