Open p5pRT opened 13 years ago
This is a bug report for perl from ikegami@adaelis.com\, generated with the help of perlbug 1.39 running under perl 5.14.0. -----------------------------------------------------------------
Hi\,
Does the "p" modifier apply to the operator (like "o") or the pattern (like "s")? It seems to me it applies to the operator.
That said\, (?:) supports p\, although it has no effect (sometimes with warning\, sometimes without).
perl -wE"'x' =~ /x/p or die; say ${^MATCH} // '-';" x
perl -wE"'x' =~ /(?p:x)/ or die; say ${^MATCH} // '-';" -
perl -wE"'x' =~ /(?-p:x)/p or die; say ${^MATCH} // '-';" Useless use of (?-p) in regex; marked by \<-- HERE in m/(?-p \<-- HERE :x)/ at -e line 1. x
Except sometimes it does have an effect.
perl -wE"$re=qr/x/p; 'x' =~ /${re}/ or die; say ${^MATCH} // '-';" x
perl -wE"$re=qr/x/p; 'xy' =~ /${re}y/ or die; say ${^MATCH} // '-';" -
And then there's the case where (?-p:) warns even though it appears to work.
perl -wE"$re=qr/x/p; 'x' =~ /$re/ or die; say ${^MATCH} // '-';" x
perl -wE"$re=qr/x/p; 'x' =~ /(?-p:$re)/ or die; say ${^MATCH} // '-';" Useless use of (?-p) in regex; marked by \<-- HERE in m/(?-p \<-- HERE :(?^up:x))/ at -e line 1. -
From a user's perspective\, none of this makes no sense. It was probably done this way so C\<\< $re = qr/.../p; $_ =~ $re >> works\, but that doesn't really make sense either. "p" should be a m// modifier\, it shouldn't be qr// modifier\, and it should be allowed in (?:).
- Eric
On Fri Oct 21 21:08:11 2011\, ikegami@adaelis.com wrote:
"p" should be a m// modifier\, it shouldn't be qr// modifier\, and it should be allowed in (?:).
doh! I meant
"p" should be a m// modifier\, it shouldn't be qr// modifier\, and it *shouldn't* be allowed in (?:).
@ikegami - Status changed from 'new' to 'open'
On Fri Oct 21 21:08:11 2011\, ikegami@adaelis.com wrote:
This is a bug report for perl from ikegami@adaelis.com\, generated with the help of perlbug 1.39 running under perl 5.14.0. -----------------------------------------------------------------
Hi\,
Does the "p" modifier apply to the operator (like "o") or the pattern (like "s")? It seems to me it applies to the operator.
That said\, (?:) supports p\, although it has no effect (sometimes with warning\, sometimes without).
perl -wE"'x' =~ /x/p or die; say ${^MATCH} // '-';" x
perl -wE"'x' =~ /(?p:x)/ or die; say ${^MATCH} // '-';" -
perl -wE"'x' =~ /(?-p:x)/p or die; say ${^MATCH} // '-';" Useless use of (?-p) in regex; marked by \<-- HERE in m/(?-p \<-- HERE :x)/ at -e line 1. x
Except sometimes it does have an effect.
perl -wE"$re=qr/x/p; 'x' =~ /${re}/ or die; say ${^MATCH} // '-';" x
perl -wE"$re=qr/x/p; 'xy' =~ /${re}y/ or die; say ${^MATCH} // '-';" -
And then there's the case where (?-p:) warns even though it appears to work.
perl -wE"$re=qr/x/p; 'x' =~ /$re/ or die; say ${^MATCH} // '-';" x
perl -wE"$re=qr/x/p; 'x' =~ /(?-p:$re)/ or die; say ${^MATCH} // '- ';" Useless use of (?-p) in regex; marked by \<-- HERE in m/(?-p \<-- HERE :(?^up:x))/ at -e line 1. -
From a user's perspective\, none of this makes no sense.
I would say *all* of this makes no sense. :-)
It makes as much sense as $x = qr/foo/g; s/$x/bar/; (which\, come to think of it\, is just like JavaScript).
Notice I didn’t add /p support to ‘use re '/flags'’.
On Sat\, Oct 22\, 2011 at 1:22 AM\, Father Chrysostomos via RT \< perlbug-followup@perl.org> wrote:
From a user's perspective\, none of this makes no sense.
I would say *all* of this makes no sense. :-)
sigh\, I'm wearing my contacts for the first time in many months\, and apparently\, that's causing me to negate everything I say! X_X
Yes\, that's what I meant\, thanks.
On Fri\, Oct 21\, 2011 at 09:08:11PM -0700\, Eric Brine wrote:
# New Ticket Created by "Eric Brine" # Please include the string: [perl #101938] # in the subject line of all future correspondence about this issue. # \<URL: https://rt-archive.perl.org/perl5/Ticket/Display.html?id=101938 >
This is a bug report for perl from ikegami@adaelis.com\, generated with the help of perlbug 1.39 running under perl 5.14.0. -----------------------------------------------------------------
Hi\,
Does the "p" modifier apply to the operator (like "o") or the pattern (like "s")? It seems to me it applies to the operator.
That said\, (?:) supports p\, although it has no effect (sometimes with warning\, sometimes without).
perl -wE"'x' =~ /x/p or die; say ${^MATCH} // '-';" x
perl -wE"'x' =~ /(?p:x)/ or die; say ${^MATCH} // '-';" -
perl -wE"'x' =~ /(?-p:x)/p or die; say ${^MATCH} // '-';" Useless use of (?-p) in regex; marked by \<-- HERE in m/(?-p \<-- HERE :x)/ at -e line 1. x
Except sometimes it does have an effect.
perl -wE"$re=qr/x/p; 'x' =~ /${re}/ or die; say ${^MATCH} // '-';" x
perl -wE"$re=qr/x/p; 'xy' =~ /${re}y/ or die; say ${^MATCH} // '-';" -
That can be explained by the fact that /${re}/ doesn't do a stringification-regexp compile roundtrip\, where /${re}y/ does. It's a side-effect of the optimization.
And then there's the case where (?-p:) warns even though it appears to work.
perl -wE"$re=qr/x/p; 'x' =~ /$re/ or die; say ${^MATCH} // '-';" x
perl -wE"$re=qr/x/p; 'x' =~ /(?-p:$re)/ or die; say ${^MATCH} // '-';" Useless use of (?-p) in regex; marked by \<-- HERE in m/(?-p \<-- HERE :(?^up:x))/ at -e line 1. -
Again\, that's due to the stringification-regexp compile roundtrip. Replacing (?-p by (?-i makes it print '-' as well.
From a user's perspective\, none of this makes no sense. It was probably done this way so C\<\< $re = qr/.../p; $_ =~ $re >> works\, but that doesn't really make sense either. "p" should be a m// modifier\, it shouldn't be qr// modifier\, and it should be allowed in (?:).
Abigail
On Sat\, Oct 22\, 2011 at 10:45 AM\, Abigail \abigail@​abigail\.be wrote:
That can be explained by the fact that /${re}/ doesn't do a stringification-regexp compile roundtrip\, where /${re}y/ does. It's a side-effect of the optimization.
Explain to whom? To me? I know that. To the users? I could be wrong\, but I don't think they care.
Migrated from rt.perl.org#101938 (status was 'open')
Searchable as RT101938$