programming-examples/perl/Array/Output two -dimensional array.pl
2019-11-15 12:59:38 +01:00

34 lines
453 B
Perl

#!/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" );