ritz0 has asked for the wisdom of the Perl Monks concerning the following question:
foreach $key (sort {$freqpage{$b} <=> $freqpage{$a}} keys %freqpage)
{
print HOTFILES "$freqpage{$key}\n";
print HOTFILES "$key \n";
}
Everything works great except when it's done I have an HTML page with ~1800 table entries. I'd like to trim this list down to just the top 20 files downloaded instead of a 900k download/redraw hell page.
How do I limit foreach? I think using a while() or for() wouldn't work because one iteration would still trigger the aforementioned foreach() loop that would *then* go through all the files. I'm out of ideas. Anyone have a suggestion?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Limits on a foreach loop
by Crulx (Monk) on Feb 04, 2000 at 00:34 UTC |