... 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 } } } ...