Just another Perl shrine | |
PerlMonks |
Re: each() function used in associative arrays gives incorrect unordered output.by Juerd (Abbot) |
on Jan 19, 2002 at 20:03 UTC ( [id://140081]=note: print w/replies, xml ) | Need Help?? |
Hashes aren't stored in the order they were defined. They're stored in whatever order perl thinks is efficient. If you had read ANY documentation on hashes, you would know that. Yes, each() gives unordered output (actually, it is ordered in a way, but the order is a bit hard to predict), but that's not incorrect. Your assumption that perl always DWYM is incorrect. (Update (200201191751+0100) Removed offensive text. Here's a list of documents that would have helped you out:
BTW, you said "... in the order as it is in the array", but didn't use any array. (The thing right of the = in your hash assignment is called a list - an array is mutable, a list is not.)
In Section
Seekers of Perl Wisdom
|
|