in reply to Re^3: Need help looping through hash
in thread Need help looping through HoH

As someone said, you can't just make stuff up and expect the computer to know what you want. :-)

Slow down. Have another look at the links you've been given and use plenty of Data::Dumper at every step. Good luck!

#!/usr/local/bin/perl use strict; use warnings; use Data::Dumper; $Data::Dumper::Indent = 1; $Data::Dumper::Sortkeys = 1; my %hash = ( '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 }, ); for my $key (keys %hash){ print qq{key: $key\n}; for my $subkey (keys %{$hash{$key}}){ print qq{\tsubkey: $subkey\n}; } }
outputs
key: summary subkey: allotments key: prefix subkey: 32 subkey: 45 subkey: 41 subkey: 44 subkey: 46 subkey: 47 subkey: 27 subkey: 43 subkey: 48 subkey: 29 subkey: 22 subkey: 40

Replies are listed 'Best First'.
Re^5: Need help looping through hash
by FunkyMonk (Bishop) on Aug 30, 2008 at 22:14 UTC
    As someone said, you can't just make stuff up and expect the computer to know what you want
    It was dominus in comp.lang.perl.misc, but he was a little more cruel than you. Read more of his pearls of wisdom if you want a laugh. Contains many naughty words and traces of nut. Beware.