2 # 'transpose' swaps rows and columns in the given tab-delimited table.
3 # syntax perl transpose.pl input.txt > output.txt
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/\s*$//g;
19 print $outline[$i]."\n";