New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
'/e' regexp modifier is not recognized by re pragma #11935
Comments
From glitchmr@myopera.comCreated by glitchmr@myopera.comWhen '/e' modifier is used with 're' module, Perl complains about unknown C:\Users\Konrad>perl -e "use re '/e'" Perl Info
|
From @jkeenanOn Sat Feb 04 04:05:02 2012, glitchmr@myopera.com wrote:
Agreed. I couldn't find any discussion of '/e' in 'perldoc re'
|
The RT System itself - Status changed from 'new' to 'open' |
From @ikegamiOn Sat Feb 04 04:05:02 2012, glitchmr@myopera.com wrote:
That message is accurate.
"e" is not a regular expression flag. It is a substitution operator flag. |
From @ikegamiOn Sat Feb 04 16:15:49 2012, ikegami@adaelis.com wrote:
Also note that "e" is not mentioned in perlre. The regex flags are (as (I find this very odd that p, g and c are regex flags instead of match |
From tchrist@perl.com"Eric Brine via RT" <perlbug-followup@perl.org> wrote
That's incorrect, and potentially misleading. With blank lines removed for brevity, these are =head2 Pattern Modifiers That's all. Those apply to patterns. These flags, however, apply to the match operator, which is different: =head2 The m// Operator (Matching) Here are the s/// flags: =head2 The s/// Operator (Substitution) And tr/// has its own as well: =begin table picture tr/// Modifiers See? Four distinct sets of flags.
You should find it odd, because they aren't. $ perl -E 'use re "/e"; say "ok"' $ perl -E 'use re "/g"; say "ok"' $ perl -E 'use re "/c"; say "ok"' $ perl -E 'use re "/p"; say "ok"' What's going on with the first three is that it isn't properly dying. $ perl -Mwarnings=FATAL,all -E 'use re "/g"; say "ok"' That's a bug. What's going on with the last one is more subtle. /p can be Anyway, probably perlre should be clearer (read: more correct) --tom |
From @ikegamiOn Sat, Feb 4, 2012 at 8:24 PM, Tom Christiansen <tchrist@perl.com> wrote:
You removed "g" and "c", but they are accepted in patterns.
|
From @ikegamiOn Sat, Feb 4, 2012 at 8:24 PM, Tom Christiansen <tchrist@perl.com> wrote:
With blank lines removed for brevity, these are the only pattern modifiers: You removed "g" and "c", but they are accepted in patterns:
I don't know why that is. If anything is misleading is that they are listed as pattern modifiers - Eric |
From tchrist@perl.comEric Brine <ikegami@adaelis.com> wrote
I removed them because they are non-sensical, and I consider it a bug
Something else that's misleading is having to look in two different --tom |
From @demerphqOn 5 February 2012 01:19, Eric Brine via RT <perlbug-followup@perl.org> wrote:
Just to note, perlre does not decide this. regexp.h does.
Huh?! /p relates to how we manage /g relates to how match /c relates to how we match. None of them have anything to do with substitution. On the other hand /e does, as does /ee Yves -- |
From @demerphqOn 5 February 2012 05:48, Eric Brine <ikegami@adaelis.com> wrote:
Personally I consider "ignored and produce warnings" to be quite Yves -- |
From @demerphqOn 5 February 2012 11:56, Tom Christiansen <tchrist@perl.com> wrote:
Why? You think throwing a fatal is preferred? They do nothing, they
Yes agreed. Yves -- |
From tchrist@perl.com
How can this not be a bug? $ perl -E 'no warnings; use re "/g"; say "gosh that was ok, then, eh?"' $ perl -E 'use warnings FATAL => "all"; use re "/g"; say "gosh that was ok, then, eh?"' $ perl -E 'use warnings FATAL => "all"; use re "/WTF"; say "gosh that was ok, then, eh?"' I can't disable them. Yes, I want a fatal. I certainly want to be *able* to have a fatal. I think they should be a fatal. They most definitely shouldn't be noise. --tom |
From @demerphqOn 5 February 2012 02:24, Tom Christiansen <tchrist@perl.com> wrote:
Please Tom, it is very difficult to discuss things that are a mass of
....
....
tr/// has nothing to do with the regex engine, IMO it has no place in
I personally would analyse modifiers in a very different way. As far as I am concerned there are only three types of regex modifier. 1. Modifiers which change the semantics of how a pattern is interpreted /m /s /i /u /d /l /a 2. Modifiers which change the behavior of the matching process or how /x /o /g /c /p 3. Modifiers which change the behavior of the substitution process. /e /ee /r
I don't really understand this analysis. This is a new feature, what
This one is pretty weird. It makes some sense, but I cant help but
Is it, it seems like it warns, which would be a deliberate action, so
Correct.
Erm, maybe, but personally I would not document it the way you did. It cheers -- |
From @demerphqOn 5 February 2012 18:44, Tom Christiansen <tchrist@perl.com> wrote:
My personal feeling on this is that it matches the general tradition I did not implement the feature, but considering the warning was
So then fix your code.
Well, I personally could see it either way, and am inclined slightly
Warnings are noise? Yves -- |
From tchrist@perl.com
Warnings that are not subject to the warnings pragma are not I cannot enable them. Yes, they're noise. --tom |
From @demerphqOn 5 February 2012 19:01, Tom Christiansen <tchrist@perl.com> wrote:
Oh, I see.
Well the fact that you cant do this ddes seem like a bug, I Yves -- |
From tchrist@perl.comdemerphq <demerphq@gmail.com> wrote
Guilty. Sorry. Yes, you're right. Am rushed.
I don't want people slingshotting around looking for where the devil the The four (or five) pick-your-own-quotes pseudofunctions qr//, m//, s///, Also, all four (or five) of the flaggy PYOQ pseudofuncs can be found $ perl -E 'say "frobnitz" =~ qr/([AEIOUWY])/i' And s///'s /r modifier does exactly the same thing as tr///'s /r % perl -E 'say "frobnitz" =~ y/aeiouy/yuoiea/r' But I do understand that tr/// doesn't belong in a section on pattern The tr/// transliteration operator does not interpolate variables; it
Wait, you mean the RHS not the LHS, right? That's why you But why mention /ee distinct from /e? It's not special.
I figure people looking for what modifiers they can apply to The /dual things are so strange. They're a mutually-dependent We could use a better way to do things. I'd like to figure out a way to make I find qr/PATTERN/msixpodual to be way out there, and adding in Plus now those aren't even listed in the same order as the m//flags are, Might as well use /mxyzptlk after all, eh? --tom |
From @khwilliamsonOn 02/05/2012 11:27 AM, Tom Christiansen wrote:
Patches welcome! |
From @demerphqOn 5 February 2012 19:27, Tom Christiansen <tchrist@perl.com> wrote:
These things happen. But please *do* try.
Well fair enough. You are talking about a book tho, and I was more
They dont change how _substitution_ is performed. They change how the You see, the way you are analysing overlooks the following (to me) Any modifier that affects a qr// is legal in an m// Or in other words: qr// compiles a pattern, m// compiles a pattern and Your analysis seesm to ignore this heirarchy in a way that I do not
Yes I know, but /ee and /eeee are synonyms. And /ee *is* distinct from
But they are collected in a way that is not useful.
Not much choixe there.
I dont understand your point here really. We have certain modifiers cheers, -- |
From @tamiasOn Sun, Feb 05, 2012 at 07:46:55PM +0100, demerphq wrote:
/ee and /eeee are not synonyms. /ee performs two evals; /eeee performs Ronald |
From @ikegamiOn Sun, Feb 5, 2012 at 12:22 PM, demerphq <demerphq@gmail.com> wrote:
Perl disagrees.
|
From @demerphqOn 5 February 2012 23:12, Eric Brine <ikegami@adaelis.com> wrote:
No it does not. I said "relates to how we match", which means "the m// modifier". Not
$ perl -e'm/foo/g' cheers, -- |
From @demerphqOn 5 February 2012 22:33, Ronald J Kimball <rjk@tamias.net> wrote:
I stand corrected, thanks for pointing that out, I definitely did not know that. $ perl -wle'sub foobar{"zoo"}; sub zoo { "giraffe" }; $_=qq("foo"); I do wonder if this is intentional or an interesting implementation side effect. Yves -- |
From tchrist@perl.com
It's been that way since time immemorial, but I can no longer --tom |
From @pjcjOn Mon, Feb 06, 2012 at 04:18:38AM -0700, Tom Christiansen wrote:
And it's seen far less frequently nowadays. Back then we had a general -- |
From tchrist@perl.comPaul Johnson <paul@pjcj.net> wrote
What, /ee? It's the normal way to get single variables interpolated. A single /e is like an eval { }, and compiled at compile time. But I never much go beyond that, because that's writing --tom |
From @ikegamiOn Mon, Feb 6, 2012 at 5:42 AM, demerphq <demerphq@gmail.com> wrote:
You said "Huh?!" when I said g, c and p are match and substitution operator Perl gives errors when you use "g" and "c" as regex flags. $ perl -e'qr/foo/c' $ perl -e'qr/foo/g' $ perl Useless (?g) - use /g modifier in regex; marked by <-- HERE in m/(?g <-- $ perl Useless (?c) - use /gc modifier in regex; marked by <-- HERE in m/(?c <-- $ perl -we'use re "/g";' $ perl -we'use re Unknown regular expression flag "c" at -e line 1 [It doesn't give errors for /p, though. but I don't see how that makes any which means "the m// modifier". Not
Exactly. Since qr// doesn't actually match, only regex pattern flags can be - Eric |
From @demerphqOn 6 February 2012 20:48, Eric Brine <ikegami@adaelis.com> wrote:
Ah, I see, this is a misunderstanding. "match and substitution
Here you seem to use "regex flags" where I would say "pattern
Do you find it productive when someone says something that you did not
This one is pretty obvious. It does not make any sense for _part_ of a
ditto.
I guess somebody MIGHT want every match to be global, but it seems
Ditto.
Tom explained this already. /p can be embedded in any pattern and it Having said that, in hindsight it probably was a mistake to allow /p on a qr//.
I find the term "regex flags" to be ambiguous and "Regex pattern 1. Pattern semantics flags: /m /i /s /u /d /l /a These modifiers change the meaning of specific meta-character, or 2. Pattern compilation flags: /x /o These patterns change the process by which a pattern is compiled. /x 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, as it does not fit well into any of Yves -- |
From @ikegamiOn Mon, Feb 6, 2012 at 9:23 PM, demerphq <demerphq@gmail.com> wrote:
oops, typo!
Here you seem to use "regex flags" where I would say "pattern
Noted. And yes of course Perl complains when you use a modifier which controls how the match is performed on a
That's good. That's what I would expect. The problem is that perlre lumps I find the term "regex flags" to be ambiguous and "Regex pattern
perlre simply calls them "modifiers" and "flags modifiers". The re pragma
Sounds good. A few comment/nits: I'm not sure a distinction is needed between (1) and (2), and it will lead 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 - Eric |
From @b2gillsOn Mon, Feb 6, 2012 at 11:04 PM, Eric Brine <ikegami@adaelis.com> wrote:
...
While (1) and (2) could be grouped together by what they can apply to; The phrase: If you wanted to describe both (1) and (2): I would like to note that the important words from (1) and (2) Also there is actually a difference between (1) and (2), ( Perhaps we should refer to qr// as a pattern. Just a random thought. )
If we do refer to /ee, perhaps we should note that you can append as
I agree with this. |
From @cpansproutOn Mon Feb 06 03:49:30 2012, tom christiansen wrote:
A single /e just makes the rhs an expression with no ‘eval’ and no block.
And the number of evals is one less than the number of e’s. -- Father Chrysostomos |
From tchrist@perl.com"Father Chrysostomos via RT" <perlbug-followup@perl.org>
I was using eval in the sense of "to evaluate an expression", not eval in 0. s/PATTERN/QQ_STRING/; In case 1, the replacement value is the result of evaluating EXPR. I don't think it is forbidden to speak of evaluating expressions
The number of evaluations is equal to the number of e’s. --tom |
From @cpansproutOn Sun Feb 12 07:18:57 2012, tom christiansen wrote:
I was wrong about there being no block. There is a block in s///e, but
‘Evaluate’ is fine, but don’t call it ‘eval’, as that refers to Perl’s
-- Father Chrysostomos |
From @cpansproutOn Sun Feb 05 09:55:52 2012, demerphq wrote:
The re pragma has always warned about invalid flags, rather than $ perl5.6.2 -e 'use re "/a"' -- Father Chrysostomos |
From @cpansproutOn Sun Feb 05 10:28:38 2012, tom christiansen wrote:
qr// is allowed on the rhs of =~ simply because arbitrary expressions
It’s useful for working around bugs. $u = ",echle etn sJ"; That example uses substitution, so the workaround is my $qr = qr/(.)/ -- Father Chrysostomos |
From @jkeenanOn Sun Feb 12 11:33:28 2012, sprout wrote:
Discussion in this RT petered out about 12 months ago. Is there still a bug in Perl which needs addressing? Thank you very much. |
Migrated from rt.perl.org#109798 (status was 'open')
Searchable as RT109798$
The text was updated successfully, but these errors were encountered: