Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It is specifically guaranteed that this is undependable.</p> <p>See the <a href="http://perldoc.perl.org/perlsec.html#Algorithmic-Complexity-Attacks" rel="nofollow">Algorithmic Complexity Attacks</a> section of <code>perlsec</code> in full. Despite its regrettable incoherency, it states that</p> <ul> <li>in 5.8.1, the order is guaranteed to be random every time.</li> <li>in 5.8.2 and later, the order will be the same unless Perl detects pathological behavior (specifically, a series of keys that would all hash to a small number of buckets, causing the hash performance to suffer). In those cases, "the function is perturbed by a pseudorandom seed".</li> </ul> <p>The documentation does <em>not</em> guarantee that the ordering will always be the same; in fact, it specifically states that it will <em>not</em> be predictable in a pathological case. Should the hashing function be changed in a future release, it's possible that data which previously did not generate degenerate hashing would now do so, and then would be subject to the random perturbation.</p> <p>So the takeaway is that if you're not using 5.8.1, <em>maybe</em> you'll get the same order, and <em>maybe</em> it won't change when you update your Perl, but it might. If you are using 5.8.1, then a random order is <em>guaranteed</em>.</p> <p>If you want a dependable order, use one of the CPAN classes that provides a hash that has a guaranteed key order - <a href="http://p3rl.org/Tie%3a%3aHash%3a%3aIndexed" rel="nofollow">Tie::Hash::Indexed</a>, <a href="http://p3rl.org/Tie%3a%3aIxHash" rel="nofollow">Tie::IxHash</a> - or just sort your keys. If you have a hash that has less than a few thousand keys, you probably won't notice an appreciable difference. If it has more than that, maybe you should consider a heavier-weight solution such as a database anyway.</p> <p>Edit: and just to make it more interesting, <a href="http://www.perlmonks.org/?node_id=1005122" rel="nofollow">keys will be randomly ordered as of 5.18</a>. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload