Pedro A Reche Gallardo wrote:
: Hi all, I have a file with 20 columns of positive and negative decimal
: numbers (eg: 9.782 -8.983) separated by a black space, and everycolumn
: is marked on top with an single alphabet letter.
: This is an example.
:
: 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
:
: Any help, or suggestion will be welcomed.
split() will return a list that can be indexed:
$_ = <>; # headers
print join(" " x 6, (split)[0,3,2,1]), "\n";
while (<>) {
chomp;
print join(" ", (split)[0,3,2,1]), "\n";
}
-- tdk