http://www.perlmonks.org?node_id=462406


in reply to Re: Initializing multidimensional arrays
in thread Initializing multidimensional arrays

Cody is right on this. Just declare the array and the treat it as if it were a 5x5 matrix because as long as you treat it like one, it will be one.

I guess you could do this:

use strict; use warnings; my @matrix; $matrix[4][4];
Perl will fill in the array with undef's for you.

update: monarch is correct. It should be 4 because Perl defaults to an index of 0 for arrays unless you set the special variable $[ = 1.