in reply to Recursing a hash
It could use some major improvements, but it should be a step in the right direction. The merlyn code I used as a reference can be found at RE: permutations?.use strict; use Data::Dumper; my $h = { a => 1, b => 2, c => { d => 3, e => { f => { g => 4, h => 5, }, }, }, }; my $match; my $find = 'g'; find_me($h); print "$match\n"; sub find_me { my ($k,$v,@rest) = %{shift()}; # merlyn code ;) $match = $v if $k eq $find; find_me({@rest}) if @rest; find_me($v) if ref $v eq 'HASH'; }
jeffa
L-LL-L--L-LL-L--L-LL-L-- -R--R-RR-R--R-RR-R--R-RR B--B--B--B--B--B--B--B-- H---H---H---H---H---H--- (the triplet paradiddle with high-hat)
|
|---|