开发者

Accessing and printing Hash of array

I have a question of how to print a hash:

@language(1,2,3);
for my $i (0 .. $#language)
{
  $statement = $db->selectall_arrayref(
    "select word from words
    left outer join language
    on words.languageId = language.languageId
    where words.languageId = $language;"
  );
  %words=((@language[$language])=>开发者_如何学编程; {@$statement});
}
return %words;

How can help to print out the hash

I tried this:

foreach my $key(keys %newwordsList)
{
    print "Dozzzz: " . $key . "\n";

    for my $ind(0 .. @{$newwordsList{$key}}-1){
        print $newwordsList{$key}[$ind] . "\n";
    }
} 

But I get nothing.

and I have a question: Hash is a sequential order or not I mean the $key, because i try yo print $keys it is supposed to print 123 but it prints out 132

what is wrong?


Hash tables don't preserve insertion order. You'll need to use a different data structure, perhaps Tie::IxHash.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜