my %revhash; while (my($k, $v) = each %hash) { push @{$revhash{$v}}, $k; } for my $val (sort { $a <=> $b } keys %revhash) { my @keys = @{$revhash{$_}}; if (@keys > 1) { # only items where there's a tie print "$val is shared by @keys\n"; } }
-- Randal L. Schwartz, Perl hacker
In reply to •Re: Comparing values in a hash
by merlyn
in thread Comparing values in a hash
by cens
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |