Don't ask to ask, just ask | |
PerlMonks |
Re: File handles - there must be a better wayby stephen (Priest) |
on May 13, 2013 at 19:13 UTC ( [id://1033338]=note: print w/replies, xml ) | Need Help?? |
Leaving hundreds of filehandles open is probably a bad idea. I'm assuming that you're leaving them open in order to read them line-by-line. However, there are more scalable ways of doing that. You can get the current position of the file read buffer with:
And you can go to that file position with:
If you keep track of your position in each file, you can open one file at a time and still read through hundreds of files line-by-line. For example, here's a code snippet that reads through and prints out a cross-section of a bunch of different files, but still only opens one file at a time:
stephen
In Section
Seekers of Perl Wisdom
|
|