Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Moving data in a tree

by shoness (Friar)
on Jul 21, 2008 at 22:08 UTC ( [id://699168]=note: print w/replies, xml ) Need Help??


in reply to Moving data in a tree

There are various modules on CPAN that will help you a great deal.

With Tree::DAG_Node for instance you can traverse the tree, running methods or simply and safely pruning and splicing the leaves and branches of your tree as you go along.

Untested...

my @leaves = (); $root->walk_down('callback' => sub { if (!scalar($_[0]->daughters)) # is it a leaf? push @leaves, $_[0]; return 1; } $root->add_daughters(@leaves);

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://699168]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2024-03-19 04:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found