in reply to Re: Little things ;)
in thread Little things ;)

and

my $numkeys = (keys %hash);

is clearer still and not much longer.

I believe very strongly in clarity when programming,
"even" in Perl.

Regards,
Helgi Briem

Replies are listed 'Best First'.
Re: Re: Re: Little things ;)
by blakem (Monsignor) on Dec 15, 2001 at 01:51 UTC
    Update: hmm... on further reading, I think the original point was that you don't need the scalar instead of the notion that adding parens would clarify what keys was doing.... so, nevermind.


    Why would the parens make it any clearer? I think you might be misunderstanding whats happening here. From keys:

    In a scalar context [keys], returns the number of keys [in the hash]
    Comparing this to length (since it behaves in a similiar way) which of these is clearer:
    $x = length $y; $x = (length $y);

    It looks like you think (keys %y) behaves like @{[keys %y]}... i.e. return the list of keys, package them up into an array, then return the member count of the array.

    -Blake