Output two -dimensional array
#!/usr/bin/perl
use warnings;
use strict;
my @array;
my @array2 = (
[ 1, 2, 3, 4 ],
[ 2, 3, 4, 5 ],
[ 3, 4, 5, 6 ],
[ 4, 5, 6, 7 ]
);
my $array3 = [
[ 1, 2, 3, 4 ],
[ 2, 3, 4, 5 ],
[ 3, 4, 5, 6 ],
[ 4, 5, 6, 7 ]
];
foreach ( 0 .. $#array ) {
print( "@{ $array[ $_ ] }\n" );
}
print( "\n" );
foreach my $row ( @array2 ) {
print( "@$row\n" );
}
print( "\n$array3->[ 2 ][ 2 ]\n" );
Related examples in the same category