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:
Tom Christiansen
Date:
February 5, 2012 10:28
Subject:
Re: [perl #109798] '/e' regexp modifier is not recognized by re pragma
Message ID:
27199.1328466470@chthon
demerphq <demerphq@gmail.com> 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.

> 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.)

> 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?

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

> 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.

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

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?

--tom

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