develooper Front page | perl.perl5.porters | Postings from August 2010

[PATCH] Re: [perl #19078] wrong match order inside replacement

Thread Next
From:
Father Chrysostomos
Date:
August 1, 2010 12:19
Subject:
[PATCH] Re: [perl #19078] wrong match order inside replacement
Message ID:
649847D3-0198-47EF-83DD-BEF102E0FCEB@cpan.org
A slightly simpler case:

$ perl -le '$_="CCCGGG"; s!.!@a{print("[$&]"),/./}!g'
[C]
[C]
[C]
[C]
[C]
[C]

What’s happening is that the s/// does not reset PL_curpm for each iteration, because it doesn’t usually have to.

The RHS’s scoping takes care of it most of the time. This happens with the /e modifier and with @{...}.

In this example, though, we have a subscript, not a block. This subscript is in the same scope as the s/// itself.

The assumption that the substitution operator will never have to reset PL_curpm itself appears to be incorrect. The attached patch fixes it.

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