找到你要的答案

Q:Plus in two dimensional array in perl

Q:加上在二维数组在Perl

I have a code like that

my @table1 = ([0,0,0,0,0,0],[0,0,0,0,0,0],[0,0,0,0,0,0],[0,0,0,0,0,0]);

$table1[0][1] = $table1[0][1] + 1;

for(my $k=0;$k<4;$k++){
    for(my $l=0;$l<6;$l++){
        print "$table1[k][l] ";
    }
    print "\n";
}     

But i can't a true response from the writing section. It turns all "0".

How can i fix that? Thanks for your helping.

我有这样的代码

my @table1 = ([0,0,0,0,0,0],[0,0,0,0,0,0],[0,0,0,0,0,0],[0,0,0,0,0,0]);

$table1[0][1] = $table1[0][1] + 1;

for(my $k=0;$k<4;$k++){
    for(my $l=0;$l<6;$l++){
        print "$table1[k][l] ";
    }
    print "\n";
}     

但我不能从写作部分得到真正的回应。它变成所有“0”。

我该怎么修理?谢谢你的帮助。

answer1: 回答1:

you forgot two $'s:

print "$table1[$k][$l] ";

Standard recommendation here:

use strict;
use warnings;

at the beginning of your script, and perl itself tells you about this mistake...

你忘了两块钱了:

print "$table1[$k][$l] ";

这里推荐标准:

use strict;
use warnings;

在你的脚本开始,和Perl本身告诉你关于这个错误…

arrays  perl