snape has asked for the wisdom of the Perl Monks concerning the following question:
Hi all, I came across a program which transpose the contents in the file. I would like to know what is meant by the line : $outline[$i] = "\t" x $oldlastcol; The entire code is as follows:
Thanks.while (<MYFILE>) { chomp; @line = split /\t/; $oldlastcol = $lastcol; $lastcol = $#line if $#line > $lastcol; for (my $i=$oldlastcol; $i < $lastcol; $i++) { $outline[$i] = "\t" x $oldlastcol; } for (my $i=0; $i <=$lastcol; $i++) { $outline[$i] .= "$line[$i]\t" } } for (my $i=0; $i <= $lastcol; $i++) { $outline[$i] =~ s/\s*$//g; print $outline[$i]."\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Transpose the contents of the file
by johngg (Canon) on Jan 22, 2010 at 17:02 UTC | |
|
Re: Transpose the contents of the file
by AnomalousMonk (Archbishop) on Jan 22, 2010 at 17:26 UTC | |
by snape (Pilgrim) on Jan 22, 2010 at 18:13 UTC | |
|
Re: Transpose the contents of the file
by Marshall (Canon) on Jan 24, 2010 at 02:33 UTC |