in reply to RE: Iterate over HoH without Recursion
in thread Iterate over HoH without Recursion

++ZZamboni. Since I can see myself reusing some variation of this, here is my version of it, which just has some stylistic changes that make it slightly easier to read (for me!).
sub ZZamboni { my $hash = shift; my $level = shift; $level = $level ? $level : 0; my $tree=''; my $key; foreach $key (sort { $a <=> $b } keys %$hash) { $tree .= "\t" x $level . "$key => " ; if (ref($hash->{$key})) { $tree .= "\n" . ZZamboni($hash->{$key}, $level+1) ; } else { $tree .= $hash->{$key} . "\n"; } } return $tree; }