in reply to
Re: Possible to have regexes act on file directly (not in memory)
in thread Possible to have regexes act on file directly (not in memory)
Thus, I first would need to know if the problem could be solved theoretically, ignoring runtime problems.
Theoretically, it's quite simple. A regex is compiled to a state machine; you can read a chunk of the file, run the regex against it, and if there is no match, simply read the next chunk of the file, and feed it to the same state machine without resetting it first.
The practical problem is that Perl doesn't expose an API that allows you to continue matching with the old state of the regex engine (as well as some optimizations that look at the length of the string, which you'd have to turn off).
So one possible approach is to write your own regex compiler (or reuse one) and teach the matcher to do incremental matches.