in reply to recursive hash layer removal question
My inital thoughts: (might update it later)
Change your foreach loop into this:
if (ref $refToHash->{$a} eq 'HASH') { foreach $b (keys %{$refToHash->{$a}}) { $refToHash->{$b} = $refToHash->{$a}->{$b}; } } delete($refToHash->{$a});
The problems with your current code:
Note, if you remove the last layer with this code then the previous layer will point to empty hash reference... is that what you want? (add an else statement to the 'if (ref ..)' if it isn't
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: recursive hash layer removal question
by wertert (Sexton) on May 10, 2005 at 17:38 UTC |