Bug#718209: perl-base: m//p doesn't work if precompiled regex doesn't use it

Niko Tyni ntyni at debian.org
Mon Aug 5 19:03:09 UTC 2013


On Wed, Jul 31, 2013 at 08:46:46AM +0300, Niko Tyni wrote:
> forwarded 718209 https://rt.perl.org/rt3/Public/Bug/Display.html?id=118213
> tag 718209 fixed-upstream
> thanks
> 
> On Sun, Jul 28, 2013 at 07:04:36PM +0000, brian m. carlson wrote:
> > Package: perl-base
> > Version: 5.18.0-3
> > Severity: normal
> > File: /usr/bin/perl
> > 
> > If a regex is precompiled with qr//, but without /p, and then used in
> > $text =~ /$pat/p, the ${^POSTMATCH} variable is undefined.  If I use
> > qr//p instead, everything works fine.  This did work in Perl 5.14, so I
> > expect that despite the bad style, it should work in Perl 5.18.
> > 
> > The attached test case will die in Perl 5.18.
> 
> Looks like [perl #118213], preliminary 5.18 fix is at
> 
>  http://perl5.git.perl.org/perl.git/shortlog/refs/heads/davem/maint-5.18-118213

Interestingly, as noted in the ticket, this doesn't fix it completely.

Your testcase gets fixed, but this:

 perl -lwe '$a=qr/a/; "abbc" =~ /$a/p and print defined ${^POSTMATCH} ? "ok" : "not ok"'

is broken even on 5.14, and only fixed upstream in the bleadperl branch.

It looks like both 5.14 and 5.18 with the above fix only work as long
as either the /g modifier is used or there are capturing parens.

Dave Mitchell says in the above commit description:

> (Getting it to capture under non-/g works in 5.19.2 due to a major
> reorganisation of the pp_match/pp_subst/regexec() code, which isn't
> suitable for backporting to maint-5.18.)

so I won't try.

Are you OK with closing this bug with the partial fix to 5.18 (so it
doesn't regress from wheezy) or do you want to track the full issue
(which probably means this will stay open until 5.20)?
-- 
Niko Tyni   ntyni at debian.org




More information about the Perl-maintainers mailing list