|Perl: the Markov chain saw
Re^5: Hash order randomization is coming, are you ready?by demerphq (Chancellor)
|on Dec 02, 2012 at 09:55 UTC
It has always been the case. Keys are returned in bucket order, then top to bottom. Keys that collide into the same bucket will be stored in LIFO order. When copying a hash like so:
%copy will be identical to %orig only if the the size of the bucket array is the same and no buckets collide. If the size of the bucket array is different the key order will change.
Even if the bucket size is the same if items collide then during the copy they will reverse order relative to each other.
None of this is new. The only new thing that changes here is which keys collide, and the fact that for a given list of keys, with hash randomization eventually they will all collide with each other. Before if you were lucky and your keys didn't collide, such as in tests, then broken code might work. At least until some new key was added that changed the state of the hash.