If you don't want your $container->{KEYS} entry to build up successively as you recurse through the structure, you'd have to remove the last entry every time you encounter the 'Leaf' recursion end-point. The following would, for example, create the desired output:
... sub walkHash { my $h = shift; my $container = shift; foreach my $key (keys %$h) { if($key ne 'Leaf' && ref $h->{$key} ) { $container->{KEYS} .= $container->{KEYS} ? "/$key" : $key; walkHash($h->{$key}, $container); } else { #Process hash under 'LEAF' key here. print Dumper($container); $container->{KEYS} =~ s#/[^/]+$##; # remove last entry } } } ...
In reply to Re: Process hash
by Eliya
in thread Process hash
by tart
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |