On Jun 5, Paul said:
>> > 3/8
>>
>> No, it means 3 out of the 8 buckets allocated have been used. This
>> doesn't tell you the number of keys, unless (by some terrible
>> misfortune) all your keys have found their way into unique buckets.
>
>Another thing -- does it always tell you how many buc
I would recommend the other answers over my own.
my $cnt = scalar keys %hash;
seems more readable to me.
Paul
--- Doug Johnson <[EMAIL PROTECTED]> wrote:
> Perfect! Thanks a million..
>
> Doug
>
>
>
> --- Doug Johnson <[EMAIL PROTECTED]> wrote:
> > In an array to find the number of elem
--- Jeff 'japhy' Pinyan <[EMAIL PROTECTED]> wrote:
> On Jun 4, Paul said:
>
> > 3/8
> >
> >Which means there are 3 elements, and space has been allocated for
> 8.
>
> No, it means 3 out of the 8 buckets allocated have been used. This
> doesn't tell you the number of keys, unless (by some terri
This goes right along with my problem. How can you tell how much memory
(RAM) the hash takes?
- Original Message -
From: "Doug Johnson" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Monday, June 04, 2001 5:04 PM
Subject: RE: Find the
Perfect! Thanks a million..
Doug
--- Doug Johnson <[EMAIL PROTECTED]> wrote:
> In an array to find the number of elements in an array I :
>
> print "$#array\n";
>
> Is there a similar way to find the number of keys in a hash without
> cycling through them and without assigning the hash to
On Jun 4, Paul said:
> 3/8
>
>Which means there are 3 elements, and space has been allocated for 8.
No, it means 3 out of the 8 buckets allocated have been used. This
doesn't tell you the number of keys, unless (by some terrible
misfortune) all your keys have found their way into unique buckets
--- "Brett W. McCoy" <[EMAIL PROTECTED]> wrote:
> On Mon, 4 Jun 2001, Doug Johnson wrote:
> my $key_count = keys %HASH;
Doh. I've DONE that, and still posted that stupid suggestion. =o)
=
print "Just another Perl Hacker\n"; # edited for readability =o)
==
--- Doug Johnson <[EMAIL PROTECTED]> wrote:
> In an array to find the number of elements in an array I :
>
> print "$#array\n";
>
> Is there a similar way to find the number of keys in a hash without
> cycling through them and without assigning the hash to an array?
You can print the hash in
On Mon, 4 Jun 2001, Doug Johnson wrote:
> In an array to find the number of elements in an array I :
>
> print "$#array\n";
Nope, not quite. It returns the index of the last element. Putting your
list in a scalar context is a better way:
my $array_cnt = @array
This is what foreach does when
Doug Johnson wrote:
>
> Is there a similar way to find the number of keys in a hash without cycling
> through them and without assigning the hash to an array?
Dunno if you can avoid counting them, but $keycount = keys(%hash) will
do what you want. Hopefully there's an optimization somew
In an array to find the number of elements in an array I :
print "$#array\n";
Is there a similar way to find the number of keys in a hash without cycling
through them and without assigning the hash to an array?
Doug
11 matches
Mail list logo