http://qs321.pair.com?node_id=187772

moof1138 has asked for the wisdom of the Perl Monks concerning the following question:

Is there a really simple way to get a random key from a hash? I have been doing this:
#assuming we have %knockknocks populated with many knock knock jokes my @setups = keys %knockknocks; my $jokekey = $setups[rand @setups];
When I use this I keep thinking that there has to be a better way to do this without an intermediate array, but I could not find anything in the docs or the Cookbook that addressed this.