1#!/usr/local/bin/perl 2 3 4use strict; 5 6my(%data); 7my($maxcol) = 0; 8my($rownum) = 0; 9 10# Read data 11while (<STDIN>) { 12 my(@row) = split /\t/; 13 my($colnum) = 0; 14 foreach my $val (@row) { $data{$rownum}{$colnum++} = $val; } 15 $rownum++; 16 $maxcol = $colnum if $colnum > $maxcol; 17} 18 19# Print data 20my $maxrow = $rownum; 21for (my $col = 0; $col < $maxcol; $col++) { 22 for (my $row = 0; $row < $maxrow; $row++) { 23 printf "%s%s", ($row == 0) ? "" : "\t", defined $data{$row}{$col} ? $data{$row}{$col} : ""; 24 } 25 print "\n"; 26} 27