in reply to Rotating a text File
Do you mean something like this? If not, try explaining how your problem differs. In particular, show us an example of the input and output you are after:
#! perl -slw use strict; my @table; while( <DATA> ) { push @table, [ split ]; } for my $y ( 0 .. 4 ) { for my $x ( $y+1 .. 4 ) { my $temp = $table[ $y ][ $x ]; $table[ $y ][ $x ] = $table[ $x ][ $y ]; $table[ $x ][ $y ] = $temp; } } print join "\t", @$_ for @table; __DATA__ H1-1 H1-2 H1-3 H1-4 H1-5 H2-1 H2-2 H2-3 H2-4 H2-5 val1 val2 val3 val4 val5 val6 val7 val8 val9 val10 val11 val12 val13 val14 val15
Output:
C:\test>689907.pl H1-1 H2-1 val1 val6 val11 H1-2 H2-2 val2 val7 val12 H1-3 H2-3 val3 val8 val13 H1-4 H2-4 val4 val9 val14 H1-5 H2-5 val5 val10 val15
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Rotating a text File
by Ms.Ranjan (Initiate) on Jun 03, 2008 at 18:12 UTC |