On Tue, Aug 14, 2001 at 10:59:08AM -0700, John Sands wrote:
> 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!

You're right, you shouldn't be making these kinds of assumptions.  :)

In fact, the keys operator in scalar context is optimized to just count the
number of keys, not expand the keys into a temporary list and count that. 

 
Michael
--
Administrator                      www.shoebox.net
Programmer, System Administrator   www.gallanttech.com
--

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to