in reply to each() function used in associative arrays gives incorrect unordered output.

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: As you can see, there's plenty of documentation on this subject. You just didn't read it. Next time, please RTFriendlyM before asking a question that has already been answered in great detail.

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.)

2;0 juerd@ouranos:~$ perl -e'undef christmas' Segmentation fault 2;139 juerd@ouranos:~$

  • Comment on Re: each() function used in associative arrays gives incorrect unordered output.
  • Download Code