in reply to Re: easy way to get random key from hash?
in thread easy way to get random key from hash?

I think the best technique depends on the size of your jokes hash. If you have lots of jokes, use a separate file with the technique grinder describes (that works very well for randomly selecting a line from a file). If there are just some tens of jokes, then
$joke = $knockknocks{(keys %knockknocks)[rand keys %knockknocks]};
works just as well, IMHO. Keep the easy things easy, and all that :-)