Gossamer Forum
Home : Products : Gossamer Links : Discussions :

How to count # of elements in a hash

Quote Reply
How to count # of elements in a hash
Hi there,

Does anyone know how to count the number of keys in a hash?
You can use this to get the number of elements in an array
$count=$#{$array};

but I've got a grouping hash and for the life of me can't figure out how to find out how many keys there are without scanning it twice. once to count and the second time to do what I need to do based on the count, and none of my books mention it. I need a better book.

Thanks for replying to such an inane question.

peace.

Kyle
Subject Author Views Date
Thread How to count # of elements in a hash klangan 1740 Feb 15, 2002, 7:07 AM
Thread Re: [klangan] How to count # of elements in a hash
Paul 1705 Feb 15, 2002, 7:16 AM
Thread Re: [RedRum] How to count # of elements in a hash
klangan 1700 Feb 15, 2002, 7:25 AM
Thread Re: [klangan] How to count # of elements in a hash
Paul 1689 Feb 15, 2002, 7:30 AM
Thread Re: [RedRum] How to count # of elements in a hash
klangan 1688 Feb 15, 2002, 7:40 AM
Post Re: [klangan] How to count # of elements in a hash
Paul 1690 Feb 15, 2002, 7:54 AM