develooper Front page | perl.perl5.porters | Postings from September 2011

Re: Regex warning

Thread Previous | Thread Next
From:
Karl Williamson
Date:
September 21, 2011 10:48
Subject:
Re: Regex warning
Message ID:
4E7A2345.9060103@khwilliamson.com
On 08/28/2011 12:25 AM, H.Merijn Brand wrote:
> On Sat, 27 Aug 2011 15:08:07 -0600, Karl Williamson
> <public@khwilliamson.com>  wrote:
>
>> On 08/26/2011 03:21 AM, H.Merijn Brand wrote:
>>> $ bleadperl -we'$_="{";m/\b$_\b/'
>>> "\b{" is deprecated; use "\b\{" instead in regex; marked by<-- HERE in m/\<-- HERE b{\b/ at -e line 1.
>>>
>>> I don't think this is desired behavior. Yes I know \Q$file\E would be
>>> appropriate here, but the error/warning could have been better.
>>>
>>
>> What do you suggest?
>
> $ bleadperl -we'$_="{";m/\b$_\b/'
> "\b{" is deprecated; use "\b\{" instead in regex; marked by<-- HERE in m/\<-- HERE b$_\b/ at -e line 1.
>                                                                                     ^^^
>
> possible?
>


Almost anything is possible in software unless it is equivalent to the 
Halting problem :).  But this is actually very hard.

The regex compiler doesn't see this pattern until all the substitutions 
have already been made.  Thus, all it sees is a constant string, and 
currently has no way of knowing that the error came from a variable.  I 
suppose that the very original pattern could be passed down and then the 
error messages could try to correlate the error position with the 
original, but this is a lot of work.

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