Parsing
If the data is very orderly, you can split on each line. If we split on commata with preceding spaces, we would get the animal-toynum pairs, that we can then split on the equality sign. I would write this:
my %toys = map {split /=/, $_, 2} split /,\s*/, $line;
Interesting bits are the map function and the third argument to split in one case, but not in the other. The reasons for these are documentet in perldoc -f, and stem from list-to-hash coercion that takes place here.
You can then take a reference to the hash and stuff it into an array, like push @array, \%toys. You can then access the element like $array[5]{mouse}, which would give 3 if we just parsed the sixth line.
If the data is more complex, you have to use regexes, e.g
my %toys;
while (my $line = <>) {
while ($line =~ m{ \G \s* ([\w-]+) =\s* (\d+) (?:,|\s*$) }xgc) {
$toys{$1} += $2;
}
}
This would'nt store each line, but automatically sum the toys for each animal.
Data structures
Perl doesn't support multidimensional arrays, but arrays of arrayrefs, which boils down to the same thing.
my @AoA = (
[1, 2, 3],
[4, 5, 6],
[7, 8, 9]
);
The square brackets denote an anonymous array reference, while curlies would denote an anonymous hash reference. perldoc perldata, perldoc perllol, perldoc perlreftut and friends have more information on these.