Notice that 'mira_rep_c765:119reads**' and 'mira_rep_c1661:6reads**' have the same value. I need to find which keys have matching values. What is the easiest way to do this?
#!/usr/bin/perl
use strict;
use warnings;
my %FINALcontigs = (
'mira_rep_c765:119reads**', 'ctctactggaagactgac',
'mira_rep_c7454:54reads**', 'atggatactgcgctgttgctaactactgga',
'mira_rep_c6803:12reads**', 'atcgactggatgcagggttgtggtttcta',
'mira_rep_c1661:6reads**', 'ctctactggaagactgac',
);
my %seen_keys;
for my $ha_key (keys %FINALcontigs) {
push @{$seen_keys{$FINALcontigs{$ha_key}}}, $ha_key
}
for my $ha_key (keys %seen_keys) {
if(@{$seen_keys{$ha_key}} > 1) {
print "\nDuplicate keys for value $ha_key:\n";
print "$_\n" for (@{$seen_keys{$ha_key}});
}
}