perlthirst has asked for the wisdom of the Perl Monks concerning the following question:
how to find a number of keys in a hash with out declaring temporary array?
I am able to get number of keys in a hash, by using the following method
use strict; use warnings; my %data= ( 'a' => 'b', 'c' => 'd', 'e' => 'f' ); my @keylen = keys %data; print $#keylen;
But here I have used array named as keylen and then i got the total number of keys.
Is it possible to take in a step. Kindly advice.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: find a number of keys in a hash
by setebos (Beadle) on Jan 16, 2009 at 14:25 UTC | |
|
Re: find a number of keys in a hash
by Fletch (Bishop) on Jan 16, 2009 at 14:26 UTC | |
by MidLifeXis (Monsignor) on Jan 16, 2009 at 19:35 UTC | |
|
Re: find a number of keys in a hash
by jwkrahn (Abbot) on Jan 16, 2009 at 14:25 UTC |