in reply to Re: Deallocating HASH pointer
in thread Deallocating HASH pointer

you might even want to do:
undef $tree
this will remove the complete $tree variable from your scope, not just 'undef' it.