Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Moving data in a tree

by shoness (Friar)
on Jul 21, 2008 at 22:08 UTC ( #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
Node Status?
node history
Node Type: note [id://699168]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (1)
As of 2020-10-24 08:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (242 votes). Check out past polls.

    Notices?