Re: SWAPING COLUMNS

2001-06-08 Thread Jos I. Boumans
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 = } ### split $in on a newline and for as long as that goes, execute all in the for loo

Re: SWAPING COLUMNS

2001-06-08 Thread Jos I. Boumans
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 = } ### split $in on a newline and for as long as that goes, execute all in the for loo

Re: SWAPING COLUMNS

2001-06-08 Thread Jeff 'japhy' Pinyan
On Jun 8, Pedro A Reche Gallardo said: >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. >A D C B >9.782 -8.983 -3.483 -3.219 >0.995 -0

Re: SWAPING COLUMNS

2001-06-08 Thread Pete Emerson
Sorry to reply to my own post, but I just looked carefully at Ondrej's solution, and the nice thing about it is that it doesn't matter what order the columns are in, it will always sort on the header. So his program is a lot more generic than mine. Nice! Pete Pete Emerson wrote: > Here's my

Re: SWAPING COLUMNS

2001-06-08 Thread Timothy Kimball
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.

Re: SWAPING COLUMNS

2001-06-08 Thread Pete Emerson
Here's my version. It's pretty straightforward, but maybe Ondrej's solution is far better for some reason? #!/usr/bin/perl -w use strict; my $inputfile; my $outputfile; $inputfile='myinfile.txt'; $outputfile='myoutfile.txt'; open (INFILE, "$inputfile") || die "Can't open input file\n"; open (OU

Re: SWAPING COLUMNS

2001-06-08 Thread Ondrej Par
#!/usr/bin/perl -w use strict; ## get first line with col names my $headers = <>; ## store column names into array my @column_names = split /\s+/, $headers; ## print out first line (sorted column names) print join(' ', sort @column_names), "\n"; ## The hash %column_order will contain column na