$hk = (keys %hash)[int(rand(scalar(keys %hash)))]; $hv = $hash{$hk};