I think what I need is an Array of Array of Hash, but I have no idea how to make that.
Can Perl do that?
And if so, how would the code look like?
I think what I need is an Array of Array of Hash, but I have no idea how to make that.
Can Perl do that?
And if so, how would the code look like?
You can address elements of such a data structure thus:
$x->[1][2]{foo} = "hello"
You don't even have to pre-define the structure. Just start working with the elements as if they're already there.
my $aah =
[ # outer array
[ # first inner array
{ # first inner hash
foo => 'bar',
},
{ # second inner hash
bar => 'baaz',
},
],
[ # secnd inner array
#...
],
# ...
];
You can access the elements like this:
$aah->[0]->[1]->{bar} # => 'baaz'
my $arr =
[
[
{key1 => $value1, key2 => $value2},
{key1 => $value3}
],
[
{rubbish => 'nonsense'},
]
];
etc.
perldoc perldsc
is a good document to read to get an idea of data structures in Perl.