in reply to Dereferencing array of hashes
Building upon LanX's reply, perhaps the following will be helpful. Also note that it's not necessary to use a C-style loop here:
use strict; use warnings; my @AoH = ( { a => "a1", b => "b1", c => "c1", }, { d => "d1", e => "e1", f => "f1", }, { g => "g1", h => "h1", i => "i1", }, ); for my $i ( 0 .. $#AoH ) { for my $key ( keys %{ $AoH[$i] } ) { print "$key => $AoH[$i]{$key}\n"; } print "\n"; }
Output:
c => c1 a => a1 b => b1 e => e1 d => d1 f => f1 h => h1 g => g1 i => i1
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Dereferencing array of hashes
by Not_a_Number (Prior) on Nov 11, 2013 at 20:27 UTC | |
by Kenosis (Priest) on Nov 11, 2013 at 20:41 UTC | |
by Not_a_Number (Prior) on Nov 11, 2013 at 21:05 UTC | |
by Laurent_R (Canon) on Nov 11, 2013 at 22:33 UTC | |
by AnomalousMonk (Archbishop) on Nov 12, 2013 at 03:47 UTC | |
by Kenosis (Priest) on Nov 11, 2013 at 21:46 UTC |