in reply to Dereferencing array of hashes
Also note that it's not necessary to use a C-style loop...
Yes, sure, but you don't even need a $i variable to loop on the array and make a real Perl loop using directly the reference. This makes the dereferencing simpler.
which will print: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 $hashref (@AoH) { print "$_ => $$hashref{$_}\n" for (keys %$hashref); }
$ perl aoh.pl 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 AnomalousMonk (Archbishop) on Nov 11, 2013 at 20:17 UTC | |
by Laurent_R (Canon) on Nov 11, 2013 at 22:50 UTC |