develooper Front page | perl.perl5.porters | Postings from June 2008

Re: [perl #35877] \n after $ in regex (was: Strange regexfailure?)

Thread Previous | Thread Next
From:
Bram
Date:
June 2, 2008 13:53
Subject:
Re: [perl #35877] \n after $ in regex (was: Strange regexfailure?)
Message ID:
20080602225227.zxhvu2wmd4w8k0so@horde.wizbit.be
Quoting David Nicol <davidnicol@gmail.com>:

> On Sun, May 25, 2008 at 8:24 AM, Zefram <zefram@fysh.org> wrote:
>
>> The latter is expected: $\ gets interpolated.
>
>
> Warn that non-final $ will interpolate in documentation and suggest   
> \Z instead?
>

Given how easy it is to miss it I feel more for a
'Possible unintended interpolation of $\ in regex' warning. (if that  
is even possible of course)

It will, obviously, result in false posistives in some regexes...  
(although I can't remember ever using $\ in a re)


Doing a grep on perl-current seems to get only this as relevant lines:  
(assuming I didn't remove too much, started with:  grep -r '[^\\]\$\\'  
* and then removing irrelevant lines)

ext/Compress/Raw/Zlib/private/MakeUtil.pm:          exit 1 if  
/^\s*local\s*\(\s*\$$\^W\s*\)/;           \
ext/Compress/Zlib/private/MakeUtil.pm:      exit 1 if  
/^\s*local\s*\(\s*\$$\^W\s*\)/;           \
ext/IO_Compress_Base/private/MakeUtil.pm:           exit 1 if  
/^\s*local\s*\(\s*\$$\^W\s*\)/;           \
ext/IO_Compress_Zlib/private/MakeUtil.pm:           exit 1 if  
/^\s*local\s*\(\s*\$$\^W\s*\)/;           \

Looking at the one in Compress::Zlib::private::MakeUtil:

     my $postamble = '

MyTrebleCheck:
	@echo Checking for $$^W in files: '. "@files" . '
	@perl -ne \'						\
	    exit 1 if /^\s*local\s*\(\s*\$$\^W\s*\)/;		\
          \' ' . " @files || " . '				\
	(echo found unexpected $$^W ; exit 1)
	@echo All is ok.

';


(Which leaves me wondering if it is intended or not)



Any comments on the warning?


Kind regards,

Bram



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