Ok, here's some quick and dirty code... not very functional under 'strict'
like this, but it would get the job done:

### open the input file ###
open I, "1.txt";

### read it all into $in ###
{ local $/; $in = <I> }

### split $in on a newline and for as long as that goes, execute all in the
for loop ###
for(split /\n/, $in) {
    ### split the given line on a space ###
     my @baz = split ' ', $_;

    ### now assign the first one to @a, the 2nd value to @b and so on ###
     push @a, shift @baz;
     push @b, shift @baz;
     push @c, shift @baz;
     push @d, shift @baz;
}

### now we shift the arrays so the FIRST element of the array becomes the
key to a hash ###
### ie, that means that the hash would have key 'A' for example, and it's
value would be an array reference filled with the values in that column ###
for ("a".."d") { $href->{shift @$_} = \@$_; }

### with this you can check if they are all there etc... just a small check
###
for (keys %$href) { print "$_ = ", @{$href->{$_}}, "\n" }

again, my apologies for the 'messy-ness' of this script, but as a quick and
dirty fix, it should do the trick

hth,

Jos Boumans


----- Original Message -----
From: "Pedro A Reche Gallardo" <[EMAIL PROTECTED]>

> A      D      C      B
> 9.782 -8.983 -3.483 -3.219
> 0.995 -0.330 9.994 -4.000
>
> and, I would like to reorder them to look as follows.
>
> A      B       C     D
> 9.782 -3.219 -3.483 -8.893
> 0.995 -4.000 9.994 -0.330

Reply via email to