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 if ($outline[$i] =~ /\w/) {
15 $outline[$i] .= "\t$line[$i]";
17 $outline[$i] = $line[$i];
21 for (my $i=0; $i <= $lastcol; $i++) {
22 $outline[$i] =~ s/[\f\n\r]*$//g;
23 print $outline[$i]."\n";