8.25. Advanced: Multi dimensional array

Example 8-18. examples/arrays/matrix.pl

#!/usr/bin/perl
use strict;
use warnings;

my @matrix;


$matrix[0][0] = 0;
$matrix[1][1] = 11;
$matrix[1][2] = 12;


#print "$matrix\n";
print "$matrix[0]\n";                 # ARRAY(0x814dd90)
print "$matrix[1][1]\n";              # 11


use Data::Dumper qw(Dumper);
print Dumper \@matrix;

Actually what we have is a simple array and each element of that
array can be another (anonymous) array (reference).


If you are interested in on-site trainings by the author, please contact me directly.

Online courses:

Would you like to get
updated when I publish
the next article?

Follow me:

Google Plus Twitter RSS feed