in reply to Removing redundancy

I'm not entirely clear what you mean by "the order needs to be preserved in the first column". I assume you mean that the 1st occurence of each name should be in the same order. We can save that information in an array, while storing the col2 data in a hash:
my @order = (); my %values; while (<IN>) { my ($col1, $col2) = split; push @order, $col1 unless exists $values{$col1}; push @{$values{$col1}}, $col2 } # and now print it: foreach my $col1 (@order) { { print join("\t", $col1, @{$values{$col1}}), "\n"; }
--Dave

Replies are listed 'Best First'.
Re: Re: Removing redundancy
by dr_jgbn (Beadle) on Apr 30, 2003 at 03:37 UTC
    Thank-you all for your excellent code! I have tried most of them and they work really well.

    Dr.J