in reply to 3d arrays

Do you need to look things up by coordinates? Do you need to be able to walk through the grid in order? Do you need to be able to jump to a particular row?

How you want to get your data back is important in determining how you should store it. A simple array of arrays might suit you:

my @arr; while (my ($x, $y, $beans) = read_grid_cell) { push @arr, [$x, $y, $beans]; } # Or the equivalent map statement, if you like.
You could certainly print the grid back out later. But if you want to get at certain cells (but not be able to walk through in order), you might need a multi-dimensional hash:
my %hash; while (my ($x, $y, $beans) = read_grid_cell) { $hash{$x}{$y} = $beans; }
If you need walkability as well as individual cell access, you would have to combine techniques:
my @beans; my %grid; while (my ($x, $y, $beans) = read_grid_cell) { push @beans, [$x, $y, $beans]; $grid{$x}{$y} = $beans; } # Now you can walk through @beans, or you can lookup by $x and $y, # but don't change the beans in either spot, because they're not linke +d!

Caution: Contents may have been coded under pressure.