If you're specifically referring to "Since Perl 5.8.1 the ordering is different even between different runs of Perl...", I think the "different runs of Perl" is meant to be taken literally, i.e. executing the perl binary. I.e. when dumping the HASH_SEED value, you should in fact get different values each time (unless perl has been built with -DUSE_HASH_SEED_EXPLICIT — see perlrun):

$ PERL_HASH_SEED_DEBUG=1 perl -e1 HASH_SEED = 12018612040932336001 $ PERL_HASH_SEED_DEBUG=1 perl -e1 HASH_SEED = 4459772231957961225 ...

That being said, I still always do get the same ordering every time I do keys %hash ...   So, I'd be interested in an explanation just as much you seem to be :)

Update:  here's some test code:

#!/usr/bin/perl use Test::More; plan tests => 1; my %hash = ( "Zero","0","One","1","Two","2", "Three", "3", "Four", "4", "Five", "5", "Six", "6", ); print "$ENV{PERL_INVOCATION_COUNT}: "; # note: test string has been determined experimentally # (i.e. it might differ with your Perl) ok(join(' ', keys %hash) eq 'Five Four Three Zero Two Six One', q{same + ordering}); if (++$ENV{PERL_INVOCATION_COUNT} < 100 ) { exec $0; }

(prints 100 times "ok ..." with my Perl — despite different hash seed values)


In reply to Re: Deterministic or keys in random order by almut
in thread Deterministic or keys in random order by andreas1234567

Title:
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, details, 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, summary, 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.