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

Re^6: Pick k numbers at random -- hash keys (randomness)

by Discipulus (Canon)
on Nov 13, 2019 at 08:52 UTC ( [id://11108616]=note: print w/replies, xml ) Need Help??


in reply to Re^5: Pick k numbers at random -- hash keys
in thread Pick k numbers at random

Hello,

also hash key randomness can be influenced (I don mean this is a wise thing to do..) by ENV vars, specifically PERL_PERTURB_KEYS and PERL_HASH_SEED

perl -v This is perl 5, version 26, subversion 0 (v5.26.0) built for MSWin32-x +64-multi-thread perl -wMstrict -le "for (1 .. 8) {my @k = keys %{ { map { $_ => 1 } 0 +.. 8 } };print qq{@k};}" 2 8 5 3 0 1 4 6 7 2 0 8 5 3 1 6 4 7 2 4 7 6 1 3 8 5 0 1 4 7 6 0 8 5 3 2 2 0 8 5 3 1 7 6 4 4 7 6 1 3 5 8 0 2 3 8 5 0 6 4 7 1 2 0 5 8 3 1 6 4 7 2 set PERL_PERTURB_KEYS=0 set PERL_HASH_SEED=0x0 perl -wMstrict -le "for (1 .. 8) {my @k = keys %{ { map { $_ => 1 } 0 +.. 8 } };print qq{@k};}" 6 7 5 2 3 1 0 8 4 6 7 5 2 3 1 0 8 4 6 7 5 2 3 1 0 8 4 6 7 5 2 3 1 0 8 4 6 7 5 2 3 1 0 8 4 6 7 5 2 3 1 0 8 4 6 7 5 2 3 1 0 8 4 6 7 5 2 3 1 0 8 4 set PERL_PERTURB_KEYS= set PERL_HASH_SEED= perl -wMstrict -le "for (1 .. 8) {my @k = keys %{ { map { $_ => 1 } 0 +.. 8 } };print qq{@k};}" 2 8 4 1 6 0 3 5 7 3 5 7 8 2 4 1 6 0 5 3 7 4 1 2 8 0 6 4 1 2 8 0 6 5 3 7 7 3 5 6 0 2 8 4 1 5 3 7 1 4 2 8 0 6 7 5 3 0 6 4 1 8 2 7 3 5 6 0 8 2 1 4

see also PERL_HASH_SEED and PERL_PERTURB_KEYS both on perlrun and Algorithmic-Complexity-Attacks and order of hash and setting PERL_PERTURB_KEYS & PERL_HASH_SEED in a perl file

L*

There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11108616]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2024-04-18 05:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found