Score:0

Perl array of arrays in loop

br flag

How can I add array to list of arrays ( 2D array ) in perl ? This option not working / example:

my @db;
my $i = 0;
my @random;
while($i < 10) {
    @random = genNum(49, 6);
    @db[$i++] = @random;
}

print $db[3][1] . "\n";
Score:0
br flag

OK, I have changed a little code and it seems that is good:

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";

}
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.