2 # 'transpose' swaps rows and columns in the given tab-delimited table.
3 # syntax perl transpose.pl input.txt > output.txt
16 $oldlastcol = $lastcol;
17 $lastcol = $#line if $#line > $lastcol;
18 for (my $i=$oldlastcol; $i < $lastcol; $i++) {
19 $outline[$i] = "\t" x
$oldlastcol;
21 for (my $i=0; $i <=$lastcol; $i++) {
22 if ($outline[$i] =~ /[\w.]/) {
23 $outline[$i] .= "\t$line[$i]";
25 $outline[$i] = $line[$i];
29 for (my $i=0; $i <= $lastcol; $i++) {
30 $outline[$i] =~ s/[\f\n\r]*$//g;
31 print $outline[$i]."\n";