Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: printing largest hash value

by sulfericacid (Deacon)
on Feb 22, 2005 at 03:10 UTC ( #433232=note: print w/replies, xml ) Need Help??


in reply to printing largest hash value

This is untested but should give you an idea. There is definitely more efficent ways to do this and it'd be interesting to see other people's methods on doing this.
my $max_count = 0; foreach my $key (keys %hash) { my $count = $hash{$key}; if ($count > $max_count) { $max_count = $count; } } foreach my $key (keys %hash) { my $count = $hash{$key}; if ($count == $max_count) { print "$key $count\n"; } }


"Age is nothing more than an inaccurate number bestowed upon us at birth as just another means for others to judge and classify us"

sulfericacid

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (2)
As of 2022-01-26 13:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (69 votes). Check out past polls.

    Notices?