in reply to Tree in perl with hashes
This particular node has the name "foo" and no children. Adding a child to it, can be done like this:$node = { name => 'foo', children => [], };
where both parent and child are nodes set up as above.push @{$parent->{children}}, $child;
Use Data::Dumper (/me looks sideways to demerphq for his reaction) to see what's in your tree, for experimentation.
Of course you're free to add more fields to a node, to hold the actual data.
|
|---|