add trial owner/s info to detail page
[sgn.git] / bin / transpose_matrix.pl
blob95b1074049e79344847f2c5d39d6ac729127e7ae
1 #!/usr/bin/perl
2 # 'transpose' swaps rows and columns in the given tab-delimited table.
3 # syntax perl transpose.pl input.txt > output.txt
5 while (<>) {
6 chomp;
7 @line = split /\t/;
8 $oldlastcol = $lastcol;
9 $lastcol = $#line if $#line > $lastcol;
10 for (my $i=$oldlastcol; $i < $lastcol; $i++) {
11 $outline[$i] = "\t" x $oldlastcol;
13 for (my $i=0; $i <=$lastcol; $i++) {
14 $outline[$i] .= "$line[$i]\t"
17 for (my $i=0; $i <= $lastcol; $i++) {
18 $outline[$i] =~ s/[\f\n\r]*$//g;
19 print $outline[$i]."\n";