For a tree, you should be fine deleting the top node (or simply letting the variable holding it go out of scope).
Since perl5 uses reference counting to know when to free the space used by variables, this strategy works fine except when you have a data structure with circular references - for example when modelling a graph, or a tree in which each node also holds a reference to the top of the tree.
In such cases extra care is needed: you can either avoid circularity using weak references, or take care to clean up enough of the references by hand to allow perl to do the rest.
Hugo
In reply to Re: Deallocating HASH pointer
by hv
in thread Deallocating HASH pointer
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |