in reply to 3d arrays

perlreftut
perllol

I think an AoA should be what you need. Something in the lines of:

my $beans = [ [ 1 , 2 ], [2 , 3] ];

Here, $beans->[0][0] would have 1 bean, $beans->[0][1] 2, etc...
You don't need a "3rd dimension" for the array beacause you can have the number of beans as value.

Hope it helps,
deibyz

Note: Code untested.