in reply to setting a scalar = to a hash?

Using keys in scalar context returns the number of elements in the hash.

my $size = keys %hash;

This is a very inexpensive operation (efficient); there is no list created when you evaluate keys in scalar context. So the way you've found to do it is the correct solution.

Update:
A hashing algorithm works by allocating a series of 'buckets' into which elements are plopped. The number of buckets is large enough to distribute the elements in such a way (hopefully) that lookups can be very quick. Usually this means a few items in each bucket. There's a really good discussion on this topic in Mastering Algorithms with Perl, published by O'Reilly & Associates.


Dave