in reply to How to compare hash values within the same hash?
%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";
|
|---|