develooper Front page | perl.perl5.porters | Postings from October 2015

Re: [perl #116639] regex optimiser wrongly rejects certain matchesinvolving embedded comments

Thread Previous | Thread Next
From:
Abigail
Date:
October 19, 2015 15:30
Subject:
Re: [perl #116639] regex optimiser wrongly rejects certain matchesinvolving embedded comments
Message ID:
20151019152956.GC8552@almanda.fritz.box
On Mon, Oct 19, 2015 at 09:16:43AM -0600, Karl Williamson wrote:
> On 10/19/2015 09:07 AM, Abigail wrote:
>> On Mon, Oct 19, 2015 at 08:33:51AM -0600, Karl Williamson wrote:
>>> On 10/19/2015 08:26 AM, Abigail wrote:
>>>>       $ perl -wE '"aaaaaaaaaa" =~ /a { 1,10}/x; say $& // "UNDEF"'
>>>>       UNDEF
>>>>       $
>>>>
>>>> (In this case, it tries to match the literal string "a{1,10}" -- one
>>>> can wonder whether that's the most useful thing it could do).
>>>
>>> Note that this now give a warning, even without the '-w' command line
>>> option:
>>>
>>> 	$ blead -E '"aaaaaaaaaa" =~ /a { 1,10}/x; say $& // "UNDEF"'
>>> 	Unescaped left brace in regex is deprecated, passed through in 	regex;
>>> marked by <-- HERE in m/a { <-- HERE  1,10}/ at -e line 1.
>>> 	UNDEF
>>> 	$
>>
>>
>>
>> Yes, I know.
>>
>> Is that useful? I'd wager that of all the people who write
>>
>>      /a { 1,10}/x
>>
>> more than 99.9% of want it to behave like
>>
>>      /a {1,10}/x
>>
>> and none of them actually want to match the literal string
>>
>>     "a{1,10}"
>>
>>
>> Abigail (who has put a space after the , in /x{n,m}/ way too often).
>>
>
> I think the warning is useful, so they aren't silently deceived.  It was  
> never useful to behave as it has, but now they are warned.
>
> In 5.24, this will not compile.  In 5.26, it will behave as you and I  
> both think would be the useful way.



Excellent.


Abigail

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