in reply to Removing duplicates

my %unique; while ( my $line = <DATA> ) { chomp $line; my ( $left, $right ) = split /\s+/, $line; push @{$unique{$left}}, $right; } foreach my $key ( sort keys %unique ) { print "$_\t"; foreach my $item ( @{$unique{$key}} ) { print "$item "; } print "\n"; }

Dave

Replies are listed 'Best First'.
Re^2: Removing duplicates
by edan (Curate) on Jul 05, 2004 at 08:54 UTC

    You made the same mistake that I did at first. The OP wants to not only merge the values by keys, but also remove duplicate values for each key...

    --
    edan