NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.
All the Perl that's Practical to Extract and Report
Stories, comments, journals, and other submissions on use Perl; are Copyright 1998-2006, their respective owners.
$/ Regex (Score:2, Interesting)
This is a hard problem. Consider backtracking (stuff it back in a buffer) and greediness (how much do you read?). The trivial cases are pretty easy, but they rapidly get complex.
Re:$/ Regex (Score:2, Informative)
There have been several threads about this on p5p, and I agree with what you say. However, I think that it may be possible to make it work reasonably for non-greedy regexps, and my hunch is that most of the time non-greedy regexps would be the correct way to express most people would want for a line ending.
Here's the middle of one p5p thread on $/ regexp [develooper.com] If people are searching, I think that some of the other threads have had qr// in the subject. (Mmm. I'm linking to a message by me. Blantant self-promotio
Re:$/ Regex (Score:3, Funny)
Hmm. I could see one way that this could go...
<damian> Perl 6 will have this
<damian> Perl 6 will have this
<damian> Perl 6 will have this
<damian> Perl 6 will have this
<damian> Perl 6 will h
Re:$/ Regex (Score:3, Insightful)
<damian> Parrot will have this
<damian> Parrot will have this
<damian> Perl 6 will have this
<damian> Perl 6 will have multidimensional arrays and vectorizable functions and operations.
Re:$/ Regex (Score:1)
Yes, handling non-greedy regexes (simple alternations, bounded ranges) is possible. I could see disallowing unbounded ranges or the /m and /s flags. I wonder if that'd confuse people who don't know the implementation and the reason for the implementation, though.
Perl 6 may have what you want (Score:3, Informative)
Greedy regexes are troublesome for the same reason: in the edge cases you potentially have to scan an entire input to determine where to stop reading.
Nevertheless, despite those problems, I'm confident we'll be able to permit Perl 6 input streams to use a regex as an input record separator (they'll be per-filehandle, not global, in Perl 6).
Reply to This