NAME

Config::AST::Node::Section - Configuration section node.

DESCRIPTION

Nodes of this class represent configuration sections in the AST.

METHODS

$t = $node->subtree

Returns tree containing all subordinate nodes of this node.

@a = $node->keys;

Returns a list of names of all subordinate statements in this section.

$bool = $node->has_key($str)

Returns true if statement with name $str is present in the section described by $node.

$node->delete($name)

Deletes the node with name $name. Returns the removed node, or undef if not found.

$node->merge($other)

Merges the section $other (a Config::AST::Node::Section) to $node.

$h = $cfg->as_hash

$h = $cfg->as_hash($map)

Returns parse tree converted to a hash reference. If $map is supplied, it must be a reference to a function. For each $key/$value pair, this function will be called as:

($newkey, $newvalue) = &{$map}($what, $key, $value)

where $what is section or value, depending on the type of the hash entry being processed. Upon successful return, $newvalue will be inserted in the hash slot for the key $newkey.

If $what is section, $value is always a reference to an empty hash (since the parse tree is traversed in pre-order fashion). In that case, the $map function is supposed to do whatever initialization that is necessary for the new subtree and return as $newvalue either $value itself, or a reference to a hash available inside the $value. For example:

sub map {
    my ($what, $name, $val) = @_;
    if ($name eq 'section') {
        $val->{section} = {};
        $val = $val->{section};
    }
    ($name, $val);
}

$s = $node->as_string

Returns the string "(section)".

SEE ALSO

Config::AST, Config::AST::Node.