develooper Front page | perl.perl5.porters | Postings from June 2016

[perl #128143] Inconsistent behaviour when decoding in substitution

Thread Previous | Thread Next
From:
Dan Collins via RT
Date:
June 8, 2016 02:55
Subject:
[perl #128143] Inconsistent behaviour when decoding in substitution
Message ID:
rt-4.0.18-5618-1465354489-743.128143-15-0@perl.org
Dave, his attachment suggests that it's the other way around. Running his testcase shows me that the "odd one out" is the one corresponding to:

    s/(.)/$latin1->decode($1)/ger;

Surely, anything that $latin1->decode($1) does to trample on $1, Encode::decode('latin1', $1) will do as well? In fact, the first thing Encode::decode does is break the pass-by-reference with:

    my ( $name, $octets, $check ) = @_;

So either $latin1->decode doesn't break the reference, and modifies $1 by assigning to it, or it performs a match that Encode::decode('latin1', $1) doesn't, and modifies $1 through a regex match.

So, I ran a different testcase, Dumping $1 instead of the return from decode(), and all four testcases had only "\x80" in $1 - so it does not seem that $1 is being polluted by a pattern match in $latin1->decode(), nor does it seem that $1 is being changed by reference within $latin1->decode(), since each case should result in the attached modified test failing in some way.

I'll keep poking this, unless I'm missing something obvious.

---
via perlbug:  queue: perl5 status: open
https://rt.perl.org/Ticket/Display.html?id=128143

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