develooper Front page | perl.perl5.porters | Postings from August 2010

RE: New regex modifier flags

Thread Previous | Thread Next
Jan Dubois
August 3, 2010 23:36
RE: New regex modifier flags
Message ID:
On Tue, 03 Aug 2010, Eric Brine wrote:
> On Tue, Aug 3, 2010 at 8:53 PM, Jan Dubois <> wrote:
> > On Tue, 03 Aug 2010, karl williamson wrote:
> > >
> > > The problem is what those modifiers should be.  Perl currently allows a
> > > keyword to come right after a regex, like '/abc/lt 1'
> >
> > Is there are comprehensive list of all potential conflicts?

Ah yes, thanks!

| Any of the following immediately following the delimiter are currently
| valid, but will become a syntax error (e.g. /foo/le+1) or different valid
| code (e.g. /foo/lt+1):
|    - unless & until from /u
|    - le & lt from /l
|    - [none] from /t

I don't understand what [none] means here, and how it becomes a syntax error.

| We're precluded from using these:
|    - /a (and)
|    - /f (for, foreach)
|    - /n (ne)
|    - /w (when, while)

So this means Karl's potential implementation of (6) essentially means
that when a regexp is immediately followed by one of the 10 keywords
above, then the letters won't be interpreted as regexp modifiers, but in
every other case the letters must either be valid modifiers or will
generate a syntax error.

And we can even use /a, /f, /n, and /w with the restriction that e.g.
/ne has to be re-ordered as /en for now.

If I understand this correctly, then I certainly prefer (6) over the other
solutions, given that it preserves full backward compatibility (for 5.14),
but also lets us choose the right mnemonic characters for the new modifiers,
and avoid the abomination of double-character modifiers.

The temporary restriction on the 10 keywords does seem to forbid mostly
non-sensical or invalid modifier combinations anyways (except for /le and
potentially /ne), so it doesn't even make a practical difference anyways.


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About