Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Randomly reassign hash keys

by thomas895 (Deacon)
on Apr 26, 2017 at 16:53 UTC ( [id://1188982]=note: print w/replies, xml ) Need Help??


in reply to Randomly reassign hash keys

Perl hashes have no guarantee of key ordering. See keys and Algorithmic Complexity Attacks. You might be able to randomize the order of the keys by changing the internal parameters used by Perl.

A better solution is to do something like @randomized_keys = List::Util::shuffle(keys %hash) and then accessing the corresponding values with something like @corresponding_values = @hash{@randomized_keys} (untested).

-Thomas
"Excuse me for butting in, but I'm interrupt-driven..."

Log In?
Username:
Password:

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

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

    No recent polls found