in reply to Re: Removing redundancy in X and Y directions
in thread Removing redundancy in X and Y directions

The code that I was trying to modify was...
my %hash;
while(<DATA>){
chomp;
my @line = split /\t/;
my $first = shift @line;
push( @{$hash{$first}}, @line );
}
foreach( sort keys %hash ){
print OUT "$_\t".join("\t", sort @{$hash{$_}})."\n";
}
  • Comment on Re^2: Removing redundancy in X and Y directions

Replies are listed 'Best First'.
Re^3: Removing redundancy in X and Y directions
by kyle (Abbot) on Sep 26, 2008 at 16:10 UTC
    my %hash; while(<DATA>){ chomp; my @line = split /\t/; my $first = shift @line; $hash{$first}{$_}++ for @line; } foreach( sort keys %hash ){ print STDOUT "$_\t".join("\t", sort keys %{$hash{$_}})."\n"; } __DATA__ text1 text-a text-a text-b text-a text1 text-c text2 text-a text-b text2 text-b text-d

    All I changed was the push line and the print line. Output:

    text1 text-a text-b text-c text2 text-a text-b text-d