in reply to Accessing Array of Arrays
could possibly be made quite simpler (and also slightly faster, but that probably does not make a measurable difference) with the following syntax:for my $division (keys %AG) { # ... for my $person (@{ $AG{$division} }) { # ...
The above is untested, but this is a simple demonstration of the same idea under the Perl debugger:for my $division (values %AG) { # ... for my $person (@$division) { # ... }
I hope this helps.DB<1> %AG = ( GAHD => [ { name => "foo",}, {name => "bar",} ], GAGD +=> [ { name => "baz",}, {name => "foobar",} ] ); DB<2> x \%AG; 0 HASH(0x6005009f8) 'GAGD' => ARRAY(0x600500680) 0 HASH(0x600500740) 'name' => 'baz' 1 HASH(0x6005006e0) 'name' => 'foobar' 'GAHD' => ARRAY(0x6005007e8) 0 HASH(0x60005f150) 'name' => 'foo' 1 HASH(0x600500848) 'name' => 'bar' DB<3> for $division (values %AG) { for $person (@$division) {print $ +person->{name}, "\n"}}; baz foobar foo bar
|
|---|