develooper Front page | perl.perl5.porters | Postings from February 2012

Re: [perl #109798] '/e' regexp modifier is not recognized by re pragma

Thread Previous | Thread Next
From:
Eric Brine
Date:
February 6, 2012 21:04
Subject:
Re: [perl #109798] '/e' regexp modifier is not recognized by re pragma
Message ID:
CALJW-qE88-Pq77CWmfW7cdHU0X4XMaOLLo=LWWJektM4FvneHQ@mail.gmail.com
On Mon, Feb 6, 2012 at 9:23 PM, demerphq <demerphq@gmail.com> wrote:

> Ah, I see, this is a misunderstanding. "match and substitution
> operator flags",  to me reads quite differently to your original words
> "match substitute operator flags".


oops, typo!


> > Perl gives errors when you use "g" and "c" as regex flags.
>

>
Here you seem to use "regex flags" where I would say "pattern
> compilation (constructor) flags".


Noted.

And yes of course Perl complains
>
when you use a modifier which controls how the match is performed on a
> pattern constructor which does not actually do any matching.
>

That's good. That's what I would expect. The problem is that perlre lumps
"g", "c" and "p" into the documentation for regex pattern compilation flags.

I find the term "regex flags" to be ambiguous and "Regex pattern
> flags" to only be marginally better. Some of the terms I have used
> elsewhere in this thread are equally bad. Since this ambiguity seems
> to lead to confusion, lets try to come up with better terms. :-)
>

perlre simply calls them "modifiers" and "flags modifiers". The re pragma
calls them "flags" and "modifiers". It could definitely be improved.

---------------------------------------------
> 1. Pattern semantics flags: /m /i /s /u /d /l /a
>
> These modifiers change the meaning of specific meta-character, or
> literal text. These apply to qr//, m// and s///
>
> 2. Pattern compilation flags: /x /o
>
> These patterns change the process by which a pattern is compiled. /x
> does so by causing the regex compiler to ignore specific parts of the
> pattern passed in, and /o by determining how often it gets compiled.
> These apply to qr//, m// and s///
>

> 3. Match control flags:  /g /c
>
> These control how the matching is to proceed, and only apply to m// and
> s///.
>
> 4. Substitutions flags: /e /r
>
> These control the behavior of the substitution operator, and apply only to
> s///
>

> ---------------------------------------------
>
> Unfortunately  this leaves /p out


Sounds good. A few comment/nits:

I'm not sure a distinction is needed between (1) and (2), and it will lead
to having to the following mouthful: "(?:) accepts pattern semantic flags
and pattern compilation flags".

perlop lists /ee in addition to /e, so /ee should be listed explicitly here.

Because of where it can be used, I'd place /p under (2). (I believe it
should be in (3), but that's not how it was implemented.)

- Eric

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About