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
February 5, 2012 10:47
Re: [perl #109798] '/e' regexp modifier is not recognized by re pragma
Message ID:
On 5 February 2012 19:27, Tom Christiansen <> wrote:
> demerphq <> wrote
>   on Sun, 05 Feb 2012 18:55:22 +0100:
>> Please Tom, it is very difficult to discuss things that are a mass of
>> pod extracts. Next time either render the POD and then paste it as
>> text, or don't use POD at all.
> Guilty.  Sorry.  Yes, you're right.  Am rushed.

These things happen. But please *do* try.

>> tr/// has nothing to do with the regex engine, IMO it has no place in
>> a discussion about regular expressions.
> I don't want people slingshotting around looking for where the devil the
> /mxyzptlk modifiers get explain.
> The four (or five) pick-your-own-quotes pseudofunctions qr//, m//, s///,
> and tr/// (and y///) are distinct from the others in taking modifiers in
> the /mxyzptlk slot, whereas q//, qq//, qx//, and qw// do not.
> Also, all four (or five) of the flaggy PYOQ pseudofuncs can be found
> using the =~ operator.  Yes, even qr//, for all the good it'll do you.
>    $ perl -E 'say "frobnitz" =~ qr/([AEIOUWY])/i'
>    o
> And s///'s /r modifier does exactly the same thing as tr///'s /r
> modifier does.
>    % perl -E 'say "frobnitz" =~ y/aeiouy/yuoiea/r'
>    fribnotz
> But I do understand that tr/// doesn't belong in a section on pattern
> matching.   Had to put it somewhere, though, and I just refused to move it
> to a functions area or an operators area.  Larry stuck this in there,
> fess'ing up to the matter:
>    The tr/// transliteration operator does not interpolate variables; it
>    doesn’t even use regular expressions!  (In fact, it probably doesn’t
>    belong in this chapter at all, but we couldn’t think of a better place
>    to put it.)

Well fair enough. You are talking about a book tho, and I was more
talking about the documentation for perl.

>> 3. Modifiers which change the behavior of the substitution process.
>> /e /ee /r
> Wait, you mean the RHS not the LHS, right?  That's why you
> didn't mention /g and /gc, because they apply to s///'s LHS?

They dont change how _substitution_ is performed. They change how the
_match_process_ works. I do not see any benefit by conflating the two.

You see, the way you are analysing overlooks the following (to me)
important observation:

Any modifier that affects a qr// is legal in an m//
Any modifier legal in an m// is legal in a s///.

Or in other words: qr// compiles a pattern, m// compiles a pattern and
execute it, and s/// compiles a pattern and then uses it for
substitution. Any modifier for compiling a pattern is legal in all
three. Any modifier for executing a pattern is legal in m// and s///,
and s/// has a few modifiers which are specific to substitution.

Your analysis seesm to ignore this heirarchy in a way that I do not
consider useful. One must essentially memorize the same list three
times, instead of understand which behaviour the modifier changes.

> But why mention /ee distinct from /e?  It's not special.
> You can have /eee and /eeee if you want.  eeeeetc.

Yes I know, but /ee and /eeee are synonyms. And /ee *is* distinct from
/e. See the docs for more details.

>> Erm, maybe, but personally I would not document it the way you did. It
>> makes sense as documentation for the individual operators, but IMO the
>> division I used is much closer to the internals.
> I figure people looking for what modifiers they can apply to
> the flaggy PYOQ pseudofuncs should be able to find all those
> collected into one place.

But they are collected in a way that is not useful.

> The /dual things are so strange.  They're a mutually-dependent
> radio group where turning one on turns the others off.  Highlander
> options.

Not much choixe there.

> We could use a better way to do things. I'd like to figure out a way to make
> those real words in there, just just letters. (?x-i:foo) is fine and all, but
> we're starting to burst at the seams -- hence my /mxyzptlk remarks.
> I find qr/PATTERN/msixpodual to be way out there, and adding in
> m/PATTERN/msixpodualgc and it's just too much.  Then we get to
> (?adlupimsx-imsx) plus the alternate (?^alupimsx), and that's just
> beyond the pale.
> Plus now those aren't even listed in the same order as the m//flags are,
> so you can't have a dependable mnemonic.
> Might as well use /mxyzptlk after all, eh?

I dont understand your point here really. We have certain modifiers
which change certain behavior. I dont see how mnemonics are relevent.


perl -Mre=debug -e "/just|another|perl|hacker/"

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