in reply to get duplicates in hash array

Here is one way of doing it - output format is different than the OP requested, but IMHO, this is easier for human consumption:
use strict; use warnings; my %HoA = ( flintstones => [qw/fred barney george/], jetsons => [qw/george fred elroy/], simpsons => [qw/fred marge bart barney/] ); my %d2; for my $k(keys %HoA){ for (@{$HoA{$k}}){ push @{$d2{$_}}, $k; } } for my $k(sort keys %d2){ next unless $#{$d2{$k}} >0; print "$k:\t (", join (",",sort @{$d2{$k}}),")\n"; }
Output:
barney: (flintstones,simpsons) fred: (flintstones,jetsons,simpsons) george: (flintstones,jetsons)

            "XML is like violence: if it doesn't solve your problem, use more."

Replies are listed 'Best First'.
Re^2: get duplicates in hash array
by arunshankar.c (Initiate) on Dec 19, 2011 at 14:01 UTC
    Thank you NetWallah, It worked very well :)