Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

So, if I understand correctly, the code you posted is visibly broken and has been for a very long time.

Well yes, it is broken, that was my point for bringing it up :-). Whether it is visibly broken or not depends on whether you have any collisions. In the case you posted there are two sets of collisions, 4 and 1, and 3 and 0. (You can tell because they reverse each copy in earlier perls.) However if changed it to be 1,2,3,5,7,8 you would not have any collisions and the order would appear the same. Eg try:

my %hash = map { $_ => 1 } (1,2,3,5,7,8);

In 5.18 the order will be different for every hash. No exceptions. Here is what perlfunc will say in 5.18:

Hash entries are returned in an apparently random order. The actual r +andom order is specific to a given hash; the exact same series of operations on two hashes may result in a different order for each hash. Any inser +tion into the hash may change the order, as will any deletion, with the exc +eption that the most recent key returned by C<each> or C<keys> may be deleted without changing the order. So long as a given hash is unmodified you +may rely on C<keys>, C<values> and C<each> to repeatedly return the same o +rder as each other. See L<perlsec/"Algorithmic Complexity Attacks"> for details on why hash order is randomized. Aside from the guarantees provided here the exact details of Perl's hash algorithm and the hash traversal order are subject to change in any release of Perl.

In reply to Re^4: Hash order randomization is coming, are you ready? by demerphq
in thread Hash order randomization is coming, are you ready? by demerphq

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others meditating upon the Monastery: (4)
    As of 2018-01-21 23:41 GMT
    Find Nodes?
      Voting Booth?
      How did you see in the new year?

      Results (230 votes). Check out past polls.