I am not sure what you are getting at here. What you have presented is gobbledygook. The Array of Hash is the closest analogue to a simple 2-D array in C - it is used so that we don't have to define index 0 in an array means 'state' and index 1 in an array means 'location', i.e.
#!/usr/bin/perl -w
use strict;
use Data::Dump qw[ pp ];
my @ArrayOfHash = ( {
'state' => 'TX',
'location' => 'US',
},
{
'state' => 'Bavaria',
'location' => 'Germany',
},
);
pp @ArrayOfHash;
__END__
Prints:
(
{ location => "US", state => "TX" },
{ location => "Germany", state => "Bavaria" },
)
A 'C' array of struct is closer to AoH, but I still don't get your question. Explain where you have seen this.
Using ordered tuples, would be an AoA, and expand back to the terms say 'state' or 'location' within a foreach loop or a map.
#!/usr/bin/perl -w
use strict;
my @AoA = ( ['TX','US'],
['Bavaria','Germany'],
);
foreach my $record_ref (@AoA)
{
my ($state, $location) = (@$record_ref);
print "state = $state location=$location\n";
}
__END__
prints:
state = TX location=US
state = Bavaria location=Germany
Or
foreach my $record_ref (@AoA)
{
my ($state, $location) = (@$record_ref);
print "key = $state value=$location\n";
}
__END__
key = TX value=US
key = Bavaria value=Germany
Again, not really sure what you are getting at. |