in reply to Re^5: Hash order randomization is coming, are you ready?
in thread Hash order randomization is coming, are you ready?
First, thanks for the clarification.
However, as far as I can tell, what you are saying comes down to:
Two hashes containing identical keys and values, will iterate in different orders, unless they were constructed in exactly the same way.For example:
$h1{ $_ } = 1 for 'a'..'z';; $h2{ $_ } = 1 for reverse 'a'..'z';; print %h1; print %h2;; w 1 r 1 a 1 x 1 d 1 j 1 y 1 u 1 k 1 h 1 g 1 f 1 t 1 i 1 e 1 n 1 v 1 m +1 s 1 l 1 c 1 p 1 q 1 b 1 z 1 o 1 w 1 a 1 r 1 d 1 x 1 j 1 y 1 u 1 h 1 k 1 g 1 f 1 i 1 t 1 e 1 n 1 v 1 m +1 s 1 l 1 c 1 p 1 b 1 q 1 z 1 o 1And:
@h1{ 'a'..'z', 'A'..'Z' } = (1)x52;; delete @h1{ 'A'..'Z' };; @h2{ 'a'..'z' } = (1)x26;; print %h1; print %h2;; a 1 d 1 j 1 y 1 u 1 k 1 g 1 t 1 e 1 v 1 s 1 c 1 q 1 b 1 z 1 w 1 r 1 x +1 h 1 f 1 i 1 n 1 m 1 l 1 p 1 o 1 w 1 r 1 a 1 x 1 d 1 j 1 y 1 u 1 k 1 h 1 g 1 f 1 t 1 i 1 e 1 n 1 v 1 m +1 s 1 l 1 c 1 p 1 q 1 b 1 z 1 o 1And:
@h{ 'a'..'z', 'A'..'Z' } = (1)x52;; delete @h{ 'A'..'Z' };; %h2 = %h;; print %h; print %h2;; a 1 d 1 j 1 y 1 u 1 k 1 g 1 t 1 e 1 v 1 s 1 c 1 q 1 b 1 z 1 w 1 r 1 x +1 h 1 f 1 i 1 n 1 m 1 l 1 p 1 o 1 w 1 r 1 a 1 x 1 d 1 j 1 y 1 u 1 h 1 k 1 g 1 f 1 i 1 t 1 e 1 n 1 m 1 v +1 s 1 l 1 p 1 c 1 q 1 b 1 z 1 o 1In all cases above, two "identical" hashes were arrived at through a different sequence of operations; and that difference in the sequence of construction manifests itself in a different iteration sequence.
But that has always been the case!
The above is 5.10; but the same is also true going right back to my involvement with perl: 5.6.1.
Which makes me wonder whether your meditation isn't a little a) redundant; b) slightly scare mongery?
Please don't take that the wrong way; I'm simply trying to understand exactly what difference(s) the latest changes have actually made?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^7: Hash order randomization is coming, are you ready?
by demerphq (Chancellor) on Dec 03, 2012 at 10:59 UTC | |
by BrowserUk (Patriarch) on Dec 03, 2012 at 20:08 UTC | |
by demerphq (Chancellor) on Dec 03, 2012 at 22:48 UTC | |
by BrowserUk (Patriarch) on Dec 04, 2012 at 01:13 UTC | |
by demerphq (Chancellor) on Dec 04, 2012 at 06:41 UTC | |
| |
by jdporter (Paladin) on Dec 03, 2012 at 13:27 UTC | |
by demerphq (Chancellor) on Dec 03, 2012 at 22:54 UTC |