my $randelement = ( keys %hash )[ rand( scalar keys %hash ) ];