Programming Tips - perl: declare, initialize and use 2D arrays in perl

Date: 2012mar24 Update: 2025jul5 Language: perl Q. perl: declare, initialize and use 2D arrays in perl A. Unlike compiled languages like C++ or Java you don't declare variable to be a 2D array. In Perl you make an array of array:
my @AoA = ( [ "fred", "barney" ], [ "george", "jane", "elroy" ], [ "homer", "marge", "bart" ], );
Notice there are round brackets on the outside and square brackets on the inside. More info http://perldoc.perl.org/perldsc.html#ARRAYS-OF-ARRAYS