Re: What should /\08/ match and do?

[email protected] (demerphq)
Newsgroups perl.perl5.porters
Message-ID <[email protected]>
On 2 June 2010 12:22, Nicholas Clark <[email protected]> wrote:
> On Tue, Jun 01, 2010 at 10:38:10PM +0200, demerphq wrote:
>> On 1 June 2010 22:30, Abigail <[email protected]> wrote:
>> > On Tue, Jun 01, 2010 at 11:52:38AM -0600, karl williamson wrote:
>> > This one is sneaky as well:
>> >
>> >    $a = '(.)\1';
>> >    "aa" =~ /${a}/;      # True
>> >    "aa0" =~ /${a}0/;    # False!
>> >    "aa\x8" =~ /${a}0/;  # True!
>>
>> Wow. Those are gnarly.  Thats a great example of why using old style
>> back refs is dangerous. Might even be worth adding to the docs?
>
> Or, alternatively, that interpolation is happening too early in regexp
> compilation, such that it's possible to produce syntactically valid
> constructions by co-incidence.

Yeah, i thought that at first too, in reference to comments Dave M
made years ago in relation to embedding a qr// object in a larger
pattern.

But in terms of /strings/ I don't think it is actually correct. How
could we tell when its deliberate? People construct complex patterns
all the time out implicitly concatenated vars wheras a compiled
pattern is already compiled, so it makes sense to treat it as distinct
unit.

> (A bit like, IIRC, \N{} escapes being interpolated, and then treated as
> metacharacters)

I think thats a little different.

The problem there is that what \N{} escapes can expand to can vary
both at compile time in terms lexical-scoping AND at run time too,
with a whole tangle of subtle issues involved, like what happens when
you embed a pattern with one behaviour into a pattern that has the
same symbol mapped to a different behaviour. The fact that currently
this information is thrown away before run time made it even worse. I
think maybe Dave's idea would have solved this one, but I'm happy Karl
managed to fix it in the way he did.

cheers,
Yves


-- 
perl -Mre=debug -e "/just|another|perl|hacker/"
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.