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

Re: How to compare hash values within the same hash?

by choroba (Chancellor)
on Sep 24, 2013 at 22:39 UTC ( #1055555=note: print w/replies, xml ) Need Help??


in reply to How to compare hash values within the same hash?

Attention - when assigning to a hash, start its name with the percent sigil, not dollar:
%hash = ( key1 => 10, # ... );

To count numbers of occurrences, hashes are usually used:

my %freq; my ($max_freq, $max_value) = 0; for my $value (values %hash) { $freq{$value}++; if ($freq{$value} > $max_freq) { $max_freq = $freq{$value}; $max_value = $value; } } print "$max_value: $max_freq times\n";
لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1055555]
help
Chatterbox?
[rajesh_perl]: thanks for editing it
beech testing firefox 52.0.1
beech me me me me
beech mi
beech eieie
beech .oO( *you* don't exist, I'm only messaging to *me* self),
[beech]: *me
beech oh my *me my*

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (6)
As of 2017-03-28 07:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (327 votes). Check out past polls.