develooper Front page | perl.perl5.porters | Postings from July 2009

Re: [perl #62056] Variable expansion in same regex as \N{} escape results in compilation error.

Thread Previous | Thread Next
From:
demerphq
Date:
July 15, 2009 02:37
Subject:
Re: [perl #62056] Variable expansion in same regex as \N{} escape results in compilation error.
Message ID:
9b18b3110907150237h2180974du3c9503aac2088b87@mail.gmail.com
2009/1/8 Moritz Lenz <moritz@casella.verplant.org>:
> Elliot Shank wrote:
>> # New Ticket Created by  Elliot Shank
>> # Please include the string:  [perl #62056]
>> # in the subject line of all future correspondence about this issue.
>> # <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=62056 >
>>
>>
>> This is a bug report for perl from perl@galumph.com,
>> generated with the help of perlbug 1.36 running under perl 5.10.0.
>>
>>
>> -----------------------------------------------------------------
>> [Please enter your report here]
>>
>> Putting a variable expansion into a regex with a \N{} escape
>> results in a compilation error in 5.10.0.  For example, the
>> following program compiles:
>>
>>     #!/usr/bin/env perl
>>     use charnames ':full';
>>     m/\N{START OF HEADING}/
>>
>> However, this
>>
>>     #!/usr/bin/env perl
>>     use charnames ':full';
>>     m/$x\N{START OF HEADING}/
>>
>> results in
>>
>>     Constant(\N{START OF HEADING}) unknown: (possibly a missing
>>     "use charnames ...") in regex;
>
> This worked in perl-5.8.8, and fails in perl-5.10.0.
> So I bisected it, and this is what git-bisect says is the offending commit:
>
> fc8cd66c26827f6c2ee1aa00ab2d3b3c320a4a28 is first bad commit
> commit fc8cd66c26827f6c2ee1aa00ab2d3b3c320a4a28
> Author: Yves Orton <demerphq@gmail.com>
> Date:   Tue Sep 19 03:37:19 2006 +0200
>
>    Re: \N{...} in regular expression [PATCH]
>    Message-ID:
> <9b18b3110609181637m796d6c16o1b2741edc5f09eb2@mail.gmail.com>
>
>    p4raw-id: //depot/perl@28868

I think the right solution to this problem is to fix charnames.

Making charnames lexically scoped poses serious conceptual
difficulties in the regex engine, for IMO very very little benefit.

IMO we should just make \N{} escapes work always. And disable this
silly "charnames not in scope" behaviour. At least in regex patterns.
I mean what do we gain?

Yes
-- 
perl -Mre=debug -e "/just|another|perl|hacker/"

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