in reply to For loop problem
Whether your second requirement is fullfilled with this (lines are written in same order as in inputfile) depends on whether or not grepuse strict; open FILE, "<untested.txt" or die "Blerch: $!\n"; my @contents=<FILE>; close FILE; open OUTPUT ">outputfile" or die "Hcrelb: $!\n"; for my $d (1..10) { print OUTPUT join $\, grep (/^$d/, @contents); } close OUTPUT;
And to top it all off, you can do this even if your file does not fit into memory: use Tie::File to tie the @contents array to the file and away you go.
CU
Robartes-
Update: Clarified things a bit.
|
|---|