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.