in reply to Re: How do I select a random key from a hash?
in thread How do I select a random key from a hash?

In a scalar context, %h returns a string consisting of the number of buckets used, a slash, and the number of buckets allocated. You could have a hash with 1000 keys and only 16 buckets. Thus, your "random key" is limited to one of the first few keys in the hash.

Try $lh = scalar keys %h; instead.