in reply to Removing redundancy
my @order = (); my %hash = (); while (<DATA>) { # split line on tab my @data = split /\t/; # for keeping the order push @order, $data[0] unless $hash{$data[0]}; # make an array ref if there isnt' one $hash{$data[0]} = [] unless $hash{$data[0]}; # store it away for later push @{$hash{$data[0]}}, $data[1]; } # keeping the order here for my $col1 (@order) { # get that stored array my $aref = $hash{$col1}; # print tab-delimited, grouped on col1 and in order print join("\t", $col1, @$aref), "\n"'; }
From what I gather what you asked, this is what you're looking for. If I didn't get it right you need to be more specific ^_^
--
perl: code of the samurai
|
|---|