|Problems? Is your data what you think it is?|
Regexes on Streamsby tsee (Curate)
|on Oct 10, 2003 at 22:25 UTC||Need Help??|
I suppose this a bit of an expert question.
Doing regex matching on streams is tricky at best and in order to work really well in all cases, it would require a different regular expression engine than perl's.
So I wrote File::Stream. Not implementing a regular expression engine (insert maniac laughter here), but implementing "regexes on streams" by means of progressive buffering -> matching -> buffer expansion -> matching... (see below for some comments on inherent problems with this approach)
With the current implementation, you can already do things like this:
It can also do quite a bit more, so consider having a look at the module's synopsis, the pasting of which is considered a waste of screen space here. A few important problems, however, remain.
Most importantly, infinite regexes on streams tend to introduce infinite strings into your memory. Too bad we don't live in the ideal Turing machine world, but this can't be helped.