rethaew has asked for the wisdom of the Perl Monks concerning the following question:
Monks, please help. I need to find the unique number of values in a hash of hashes. For example, given the array below, I need to know how many kids are 12 years old.
How many kids are 12? In this case 2. Is there a quick way to get this number without looping through each hash and counting?%hoh = ( kevin => { age => "12", favorite_color => "blue", gender => "boy", }, john => { age => "11", favorite_color => "green", gender => "boy", }, lisa => { age => "11", favorite_color => "pink", gender => "girl", }, sara => { age => "13", favorite_color => "purple", gender => "girl", }, shelly => { age => "12", favorite_color => "purple", gender => "girl", }, );
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Find number of unique values in hash
by zwon (Abbot) on Jan 19, 2010 at 22:03 UTC | |
by AnomalousMonk (Archbishop) on Jan 19, 2010 at 23:26 UTC | |
Re: Find number of unique values in hash
by ww (Archbishop) on Jan 19, 2010 at 22:11 UTC | |
Re: Find number of unique values in hash
by CountZero (Bishop) on Jan 19, 2010 at 22:07 UTC | |
Re: Find number of unique values in hash
by saberworks (Curate) on Jan 19, 2010 at 22:04 UTC | |
by CountZero (Bishop) on Jan 19, 2010 at 22:16 UTC | |
by saberworks (Curate) on Jan 19, 2010 at 22:21 UTC | |
Re: Find number of unique values in hash
by jethro (Monsignor) on Jan 19, 2010 at 22:11 UTC | |
by johngg (Canon) on Jan 20, 2010 at 00:04 UTC | |
Re: Find number of unique values in hash
by kennethk (Abbot) on Jan 19, 2010 at 22:07 UTC |
Back to
Seekers of Perl Wisdom