With that said and given your example data - I would:
#!/usr/bin/perl -w use strict; my %seen; my @data; open (INPUT,"file") or die "Error accessing file : $!"; while (<INPUT>) { chomp; my ($col1, $col2) = split /\t/; if (exists $seen{$col1}) { $data[$seen{$col1} - 1] .= " $col2"; } else { $seen{$col1} = push @data , "$col1\t$col2"; } } print "$_\n" foreach(@data);
Cheers - L~R
Update: Completely re-wrote code to be unique as my original solution closely mirrored others
In reply to Re: Removing redundancy
by Limbic~Region
in thread Removing redundancy
by dr_jgbn
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |