in reply to selecting random key from hash

Your criteria are curious. You could do something like this:

$random_element = (keys %hash)[rand keys %hash];
That generates a list of all the keys each time you do it. (but it doesn't use an array! :-)