in reply to Re: Variable scoping when a sub calls itself??
in thread Variable scoping when a sub calls itself??

Don't you think it cleans too much? ;-)

cosmicperl wants to delete pairs from hashes where the values are empty hash or array refs. After your sub runs, $hashvar looks like this:

$hashvar = { 'hemp' => undef, 'emp' => undef };

No need for recursion to achieve that, perl's garbage collector does the rest when you just delete the hash values ;-)

Replies are listed 'Best First'.
Re^3: Variable scoping when a sub calls itself??
by GrandFather (Saint) on Apr 15, 2008 at 22:47 UTC

    I noticed that that was not what OP was after on re-reading the node (cf my update). My initial assumption was that OP needed to forcibly delete each node in the structure to get around leaks due to circular references or some such.


    Perl is environmentally friendly - it saves trees