in reply to Find duplicate values in hash
use Data::Dumper; my %hash = ( a => 'f', b => 'g', c => 'f', d => 'h', e => 'f', ); my %dups; while (my ($e, $g) = each %hash) { push @{$dups{$g}}, $e } while (my ($g, $e) = each %dups) { say "$g is duplicated in @$e" if @$e > 1; } print Dumper \%dups;
You seemed unsure as whether you'd produced a hash in your OP. Data::Dumper1 is an excellent tool for inspecting arbitary data structures. Used as above it shows:
[1] Actuallly, I prefer Data::Dump but it isn't a core module.$VAR1 = { 'h' => [ 'd' ], 'g' => [ 'b' ], 'f' => [ 'e', 'c', 'a' ] };
|
|---|