Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

comment on

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

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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (2)
As of 2022-12-04 19:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?