#!/usr/bin/perl -w use strict; my @a = ([1,2,3], [9,8,7,6,5]); print "$a[0][1] the 2 in first row\n"; print "$a[1][3] the 6 in the second row\n"; print "showing another way to make a 2-d thing\n"; # often the syntax that allows access to individual elements just # isn't used as often processing a whole row at once is what is needed my $rows = 3; my $cols = 4; my @x; while ($rows--) { my @rand; push(@rand, int rand(100)) foreach (1..$cols); push (@x, [@rand]); } foreach my $array_ref (@x) { print "@$array_ref\n"; } __END__ prints: 2 the 2 in first row 6 the 6 in the second row 62 44 73 13 11 14 23 73 47 22 40 9