Hi All
I am struggling to get keys to randomize the order that it returns
the key list between successive runs. My understanding was that in
5.8.1 and later, successive calls to keys would give the hash keys in
different order, but I cannot get this to work. My test case is:
#!/usr/bin/perl
@h{1..1000} = (1..1000);
@arr1 = keys %h;
@arr2 = keys %h;
print "Testing...\n";
print "array1 is ", scalar(@arr1), " elements; array2 is ", scalar
(@arr2), " elements\n";
print "Testing...\n";
foreach (@arr1)
{
print "different" if $_ ne $arr2[$i++];
}
print "end test\n";
I have checked the Perl build (5.8.7 on Mandriva Linux) and it has
not been compiled with NO_HASH_SEED. In fact perl -V reports nothing
with hash in the compile flags. When I run with env var
PERL_HASH_SEED_DEBUG=1 I see the different seed values being used
each run, so some form of randomization is being used. However, the
order that keys returns is stubbornly the same each time. I tried
making the hash bigger (1000 entries) in case my small example was
causing it, but to no avail.
Any ideas Perl gurus?
Thanks in advance
Paul Gowers
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs