you'll find perldsc an useful read for sure. But the task is not so complex: you can use some usful functions Perl offers to you. For exmple ref can tell you if a value you got fetching some key is a scalar or a hash ref. In the latter case you just to iterate over it as you've already done for the container hash.
use strict; use warnings; my %h1=('qwqw' => {'qw' => 'qww','df' => 'dfff'},); my %hash=( 'AAA' => 'aaa', 'BBB' => 'bbb', 'CCC' => {'A1' => 'a1','B1' => 'b1','C1' => {'A2' => 'a2','B2' => 'b2' +,'C2' => 'c2END'}}, 'DDD' => 'ddd', 'EEE' => \%h1, 'FFF' => 'sdsfsds', ); ddump (\%hash); sub ddump { my $ref = shift; my $deep = shift||0; foreach my $k (sort keys %{$ref}) { if (ref( ${$ref}{$k})) {print "\t" x $deep."$k =>\n"; &dd +ump (${$ref}{$k}, ($deep+1))} # key and value # else {print "\t" x ($deep)."$k => ${$ref}{$k}\n";} # or just the key as your need else {print "\t" x ($deep)."$k\n";} } } # OUTPUT AAA BBB CCC => A1 B1 C1 => A2 B2 C2 DDD EEE => qwqw => df qw FFF
L*
In reply to Re: Traversing a hash of hashes of hashes
by Discipulus
in thread Traversing a hash of hashes of hashes
by kcorj2244
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |