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]; [download]
duff