monkini has asked for the wisdom of the Perl Monks concerning the following question:
I am trying to loop over each array element with nested loop over the hash keys in each element
for (my $i = 0; $i < 3; $i++) { # array has 3 elements foreach my $key (keys @{$AoH[$i]}) { # DO STH } }
But I get a warning "Not an ARRAY reference" ...what am I doing wrong? Example data:
@AoH = ( { a => "a1", b => "b1", c => "c1", }, { d => "d1", e => "e1", f => "f1", }, { g => "g1", h => "h1", i => "i1", }, );
So I want to access a, b & c at level $AoH[0], then d, e & f at $AoH1 etc.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Dereferencing array of hashes
by LanX (Saint) on Nov 11, 2013 at 18:46 UTC | |
|
Re: Dereferencing array of hashes
by toolic (Bishop) on Nov 11, 2013 at 18:59 UTC | |
|
Re: Dereferencing array of hashes
by Kenosis (Priest) on Nov 11, 2013 at 18:59 UTC | |
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 | |
|
Re: Dereferencing array of hashes
by Laurent_R (Canon) on Nov 11, 2013 at 19:57 UTC | |
by AnomalousMonk (Archbishop) on Nov 11, 2013 at 20:17 UTC | |
by Laurent_R (Canon) on Nov 11, 2013 at 22:50 UTC |