in reply to Traversing a double hash

Each value in the hash is a hash reference, so you need to dereference the hash reference, then just treat it like a regular hash. Take a look at perlref. Here's some code:
for my $key1 (sort keys %myhash) { print $key1, "\n"; for my $key2 (sort keys %{$myhash{$key1}}) { print "\t", $key2, " => ", $myhash{$key1}{$key2}, "\n"; } }
If you just want to see what a data structure contains, use Data::Dumper:
use Data::Dumper; print Dumper \%myhash;

Replies are listed 'Best First'.
RE: Re: Traversing a double hash
by ChuckularOne (Prior) on Apr 17, 2000 at 19:25 UTC
    Just used this logic on a triple hash! Works beautifully!
    for my $key1 (sort keys %linehash) { $outSect1 = $key1; for my $key2 (sort keys %{$linehash{$key1}}) { $outSect2 = "$outSect1.$key2"; print "$outSect2\n"; for my $key3 (sort keys %{$linehash{$key1}{$key2}}) { if ($key3 ne ""){ print "\t", $key3, " = ", $linehash{$key1}{$key2}{$key3} +, "\n"; } } } }
    Your humble servant,
    -Chuck
Re^2: Traversing a double hash
by Anonymous Monk on Mar 20, 2009 at 15:12 UTC
    Thank you!