I have a 2 dimensional array. When I print/Dump this I get the following
My 2 dim array:
push (@matrix, \@a1Comparea2);
push (@matrix, \@a3Comparea4);
a1Comparea2 should be first row of array a3Comparea4 should be second row of array
$VAR1 = [
[
'1 6',
'2 7',
'3 8',
'4 9',
'5 10'
],
$VAR1->[0],
$VAR1->[0],
$VAR1->[0],
$VAR1->[0],
[
'7 12',
'8 13',
'9 14',
'10 15',
'11 16'
],
$VAR1->[5],
$VAR1->[5],
$VAR1->[5],
$VAR1->[5]
];
When I try to print this with following code:
for (my $j= 0; $j < $rows; $j++)
{
for (my $k= 0; $k < @a1; $k++)
{
print "Row:$j Col:$k = $matrix[$j][$k]\n";
}
}
I get the following output:
Row:0 Col:0 = 1 6
Row:0 Col:1 = 2 7
Row:0 Col:2 = 3 8
Row:0 Col:3 = 4 9
Row:0 Col:4 = 5 10
Row:1 Col:0 = 1 6
Row:1 Col:1 = 2 7
Row:1 Col:2 = 3 8
Row:1 Col:3 = 4 9
Row:1 Col:4 = 5 10
As you can see the data is duplicated.