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

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."

In reply to Re: Rotating a text File by BrowserUk
in thread Rotating a text File by Ms.Ranjan

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.