in reply to Re: Re: Regexes on Streams - Revisited!
in thread Regexes on Streams - Revisited!
I should note that Dominus' solution suffers from exactly the bug that tsee is trying to work around, except worse because he didn't think carefully about what happens if $/ wants to do a greedy match across a block.I think I'm misunderstanding something here then. I don't see any bug in Dominus' code.
To clarify, let me restate the problem: Given an input stream and a terminator (regex) pattern, break the stream into chunks, each ending in something the terminator matches. Naturally a problem arises when the terminator pattern matches (or contains) something potentially infinite, like qr/.*/. Then you get in memory problems, etc.
But where is a bug in that behaviour? The code is doing what it's supposed to do. How can it complete something that is impossible (provided the stream is infinite)? And I don't understand how you could work around that.
Furthermore Dominus' code should come with a caveat that it won't work entirely as expected if $/ contains a capturing set of parens.Yes, it should, but his code is a textbook example which should not have to deal with all corner cases because the focus should stay on the problem at hand. In 'real' code I'd do some kind of inspection of the regex in order to catch that. And, btw, what sense is there in putting capturing parens into a terminator pattern?
-- Hofmator
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re3: Regexes on Streams - Revisited!
by tilly (Archbishop) on Oct 16, 2003 at 14:38 UTC | |
by Hofmator (Curate) on Oct 16, 2003 at 14:49 UTC |