This works fine for my hash (which will always be fairly small) so my problem
is solved, thanks.
It seems a lot of overhead, though, to build a list of keys and count the
number of items in the list, just to say:
if (scalar(keys(%messages)) > 0) {
#do stuff
}
I thought there might be something faster. On the other hand, I'm far too new
to Perl to be making these kinds of assumptions about how the scalar and keys
functions are implemented!
-John
> > Is there a simple way to know whether a hash has items in it? Like using
> > @ARRAY in a scalar context gives the size of an array. Or using $#ARRAY
> > gives the last valid index.
>
> Calling keys() on the hash will return a list of the keys in the hash.
> Calling scalar() on that list will give you the number of elements in the
> list.
>
> Regards,
>
> Troy
__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]