in reply to Need help looping through HoH

Hi,
  Could you show us the code you are using for the Dump? As this looks like 4 variables rather than a hash. Maybe you need to be dumping as a reference with \%hash?
  As far as looping goes (untested code and it's late):-
foreach my $key (keys %hash) { print "$key = $hash{$key}\n"; }#foreach foreach my $value (values %hash) { print "value = $value\n"; }#foreach while ( my ($key, $value) = each %hash ) { print "$key = $value\n"; }#while

Lyle

Replies are listed 'Best First'.
Re^2: Need help looping through hash
by ewhitt (Scribe) on Aug 31, 2008 at 08:54 UTC
    Lyle, here is a Dump with \%hash
    $VAR1 = { 'summary' => { 'allotments' => 679 }, 'prefix' => { '32 ' => 425, '45 ' => 5, '41 ' => 2, '46 ' => 5, '44 ' => 1, '47 ' => 9, '43 ' => 1, '27 ' => 1, '48 ' => 212, '22 ' => 14, '29 ' => 2, '40 ' => 2 } };
    What I am trying to do is jump into the HoH to the keys under "prefix" and print their corresponding values. (i.e. that "32" = "425", "45" = 5...etc). Can't this be done in a single loop? Something like
    foreach my $key (keys $%hash->{'prefix'})