Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: printing largest hash value

by demerphq (Chancellor)
on Feb 22, 2005 at 09:06 UTC ( #433288=note: print w/replies, xml ) Need Help??


in reply to printing largest hash value

my %hash=(); my $highest; my @highest=grep {defined $highest ? $hash{$_}==$highest : (($highest= +$hash{$_}),1) } sort { $hash{$b} <=> $hash{$a} || $a cmp $b } keys %hash;

or

my %hash=(); my %rev; my $highest=0; for (keys %hash) { $rev{$hash{$_}}{$_}++; $highest=$hash{$_} if $highest < $hash{$_}; } print sort keys %{$rev{$highest}};
---
demerphq

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (2)
As of 2022-01-29 02:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (74 votes). Check out past polls.

    Notices?