|
|
| Don't ask to ask, just ask | |
| PerlMonks |
Re: Optimizing I/O intensive subroutineby chromatic (Archbishop) |
| on Oct 26, 2012 at 16:16 UTC ( #1001118=note: print w/ replies, xml ) | Need Help?? |
|
What happens if you return an array reference instead of an array at the end of this function? (Depending on how large $limit is, you might cause Perl to copy a lot of data.) What happens if, instead of reading the whole file into an array and then sorting it, you keep track of the largest n lines you've seen and read the file line by line? Improve your skills with Modern Perl: the free book.
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||