in reply to Looping and counting
I suppose you're fetching a row at a time within your for loops?
It might be easier fetch the first 50 headlines (by putting a LIMIT in the SQL query) and grabbing all of them at once and putting that into an array. Then, you can just output the first 10 into the first file and the next 40 into the second file.
Alternatively, you can use something like your existing for loop like so:
for ($n = 1; $n < 50; $n++) { # Fetch your row however you're doing it and put into $headline if ($n < 10) { print outfile1 $headline; } else { print outfile2 $headline; } }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Looping and counting
by htmanning (Friar) on Apr 04, 2012 at 01:30 UTC | |
by Riales (Hermit) on Apr 04, 2012 at 01:44 UTC |
In Section
Seekers of Perl Wisdom