in reply to Re^2: Removing redundancy in X and Y directions
in thread Removing redundancy in X and Y directions
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
|
|---|