On Sat, 15 Jul 2023, 10:13 Martijn Lievaart via perl5-porters, <
perl5-porters@perl.org> wrote:
> Op 14-07-2023 om 23:26 schreef demerphq:
>
>
>
> On Fri, 14 Jul 2023, 21:56 Jim Avera, <jim.avera@gmail.com> wrote:
>
>> If a regex contains an actual tab, Data::Dumper shows it as a tab rather
>> than \t.
>> Is that intentional? AFAIK replacing actual tab with \t in a regex
>> should produce the same result.
>>
>> echo -e 'perl -MData::Dumper -wE "say Dumper(qr/AAAA\tBB/)"' | sh
>> $VAR1 = qr/AAAA BB/u;
>>
>> An actual tab, of course, looks like spaces to humans. Could/should D::D
>> output \t instead?
>>
>
> I'd expect it to output the pattern that was compiled, so if it was
> compiled with \t I'd expect it to be preserved, and if it was compiled as
> the codepoint I'd expect it to be preserved also. So yeah, this seems like
> a bug, but I'm not 100% certain, I'm on my phone and haven't dug into the
> details before writing this.
>
>
> I'ld say you arguing opposite points.
>
We aren't arguing. Jim asked what should happen, and I replied wearing my
"regex engine expert" hat and said what I think should happen, with caveats.
Jim is saying an actual tab codepoint should translate to '\t' when
> Dumping(),
>
Jim gave an example where the pattern fed to a qr// included \t but which
DD output as a codepoint. He then asked whether that was correct.
while Yves is saying it should roundtrip to whatever it actually, exactly
> was on input.
>
Right. My perspective comes from the fact that escapes in a pattern are not
exactly equivalent to the codepoint that they represent in a double quoted
string. (Consider the hex version of | is not an alternation symbol inside
a qr//) It is up to the regex engine to decode them properly. Thus I think
when this pattern in a qr// is serialized it should not be converted to the
codepoint.
> Or do I misunderstand?
>
If you do it seems only that there is a dispute here, where I see a
question followed by a mostly concurring answer. I suspect that possibly
you have the impression the rules of interpolation in a qr// are the same
for a qq// when in fact they are not.
Cheers
Yves
>