Ms.Ranjan has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: Rotating a text File
by BrowserUk (Patriarch) on Jun 03, 2008 at 15:51 UTC

    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.
      Hi I apologize for not explaning the problem more clearly.. thankyou very much..this is the kind of input and output..i am working on it..thanks
Re: Rotating a text File
by igelkott (Priest) on Jun 03, 2008 at 16:04 UTC

    Do you perhaps mean Transpose?

    If your 2D array is stored as $array[$i][$j], just write it out as $array[$j][$i]. For more help, see the tutorial on 2D arrays (technically, Arrays of Arrays).

    I didn't quite get the details regarding your titles but this should get you pretty close ... as long as I understood the question correctly.

Re: Rotating a text File
by Fletch (Bishop) on Jun 03, 2008 at 15:32 UTC

    Show some sample data?

    Explain in plain language what the frell "rotate the table" means in this context?

    Read How (Not) To Ask A Question?

    The cake is a lie.
    The cake is a lie.
    The cake is a lie.