Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Find number of unique values in hash

by zwon (Abbot)
on Jan 19, 2010 at 22:03 UTC ( [id://818302]=note: print w/replies, xml ) Need Help??


in reply to Find number of unique values in hash

my $i; for (values %hoh) { $_->{age} == 12 && $i++; }

PS: ah, you want to do it "without looping through each hash and counting." No, I don't think that's possible.

Replies are listed 'Best First'.
Re^2: Find number of unique values in hash
by AnomalousMonk (Archbishop) on Jan 19, 2010 at 23:26 UTC
    rethaew want[s] to do it "without looping through each hash and counting." No, I don't think that's possible.

    I agree. Even a solution like
        my $age12 = grep $_->{age} == 12, values %hoh;
    implicitly loops through the hash. rethaew will have to wait for the arrival of the personal desktop quantum computer to solve the problem without looping.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://818302]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2024-04-24 03:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found