in reply to Re: Random hash element (low memory edition).
in thread Random hash element (low memory edition).

The order in which keys are returned by keys/each/value are supposed to be random (not crypotgraphically random, but explicity coded as random, with the random factor being different for each run (see PERL_HASH_SEED).

If they are, then my perl is quite buggy.

I ran perl -MData::Dumper -we 'print Dumper \%ENV' a few times, both with perl 5.8.8 and 5.10.0 (on Debian Etch i386), and I always got the same order.

(And this is no Data::Dumper artifact - it works with join ", ", keys %ENV as well.)

It is true that you shouldn't rely on a particular hash order, but it doesn't mean a randomized order is guaranteed.

Replies are listed 'Best First'.
Re^3: Random hash element (low memory edition).
by dave_the_m (Monsignor) on Jan 26, 2008 at 17:42 UTC
    My mistake. The first cut of the hash randomisation code always randomised, but then it was changed to only randomise in pathological cases, to avoid too much code breakage.

    Dave.