develooper Front page | perl.perl5.porters | Postings from October 2011

[perl #101938] Oddity of /p

Thread Previous | Thread Next
From:
Father Chrysostomos via RT
Date:
October 21, 2011 22:22
Subject:
[perl #101938] Oddity of /p
Message ID:
rt-3.6.HEAD-31297-1319260921-267.101938-15-0@perl.org
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'’.


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