Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I want to do something with a sorted array, and I guess after "I do something", each line will be copied in the output textfile already sorted eh? But is not sorting!#My Input text file: dec.x.bc.00041669 1067503 1067501 dec.x.bc.00019580 1067503 1067501 dec.x.bc.00016113 1067503 1067501 #I want my Output textfile: dec.x.bc.00016113 1067503 1067501 dec.x.bc.00019580 1067503 1067501 dec.x.bc.00041669 1067503 1067501 #this is my code @filenames=@ARGV; foreach my $file (@filenames) { open (INFILE, $file) || die ("Can't open file $file$!"); chomp(my @resultArray = map { /^\s*$/ ? () : $_ } <INFILE>); open(OUTFILE, ">$file.formatted"); sort { $a<=>$b } @resultArray; print Dumper \@resultArray; foreach my $line(@resultArray){ my ($ID, $ans1, $ans2) = split( / /, $line ); #do something; print OUTFILE "$lineResults\n"; } close OUTFILE; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Sort textfile
by eric256 (Parson) on Apr 13, 2004 at 20:45 UTC | |
by chromatic (Archbishop) on Apr 13, 2004 at 21:18 UTC | |
|
Re: Sort textfile
by Plankton (Vicar) on Apr 13, 2004 at 20:34 UTC | |
|
Re: Sort textfile
by Sandy (Curate) on Apr 13, 2004 at 20:49 UTC | |
by Anonymous Monk on Apr 13, 2004 at 22:02 UTC | |
by Sandy (Curate) on Apr 14, 2004 at 15:08 UTC | |
|
Re: Sort textfile
by Anonymous Monk on Apr 13, 2004 at 23:19 UTC | |
|
Re: Sort textfile
by blue_cowdawg (Monsignor) on Apr 14, 2004 at 01:40 UTC |