如何在 perl 中将数组添加到数组列表(二维数组)?此选项不起作用/示例:
my @db;
my $i = 0;
my @random;
while($i < 10) {
@random = genNum(49, 6);
@db[$i++] = @random;
}
print $db[3][1] . "\n";
答案1
好的,我修改了一些代码,看起来不错:
my @db;
my $i = 0;
my @random;
while($i < 10) {
@random = genNum(49, 6);
push( @{$db[$i++]}, @random);
}
$i = 0;
while ($i < 10) {
print join(", ", @{$db[$i++]}) . "\n";
}