in reply to Possible to have regexes act on file directly (not in memory)
For anybody who is interested, my final decision is now to implement my own pattern scanner (based on a state machine) which operates directly on the source files without using Perl's regular expression engine. I am not yet sure if I should explicitly operate on chunks or if I should rely on the O/S's buffering layer (which should enable me to read single characters from a file without performance penalty, shouldn't it?).
This approach also has the advantage that I could easily port the application to another programming language (compiler based, perhaps with assembly optimizations). Using an own pattern scanner will make this much more easier.
After having read davido's proposition of using File::Map, I initially hoped that this would be the solution. In the meantime, I have studied the documentation for this module, and if I got it right, it will read the parts of the file which actually get used into memory. Although this will happen lazily (which is a fine technique), it disqualifies the solution for that specific problem: There are enough situations where I could end up with the complete file being in memory which is exactly the thing to be avoided.
Thanks again to everybody who helped!
Nocturnus
|
|---|