develooper Front page | perl.perl5.porters | Postings from January 2005

Re: [perl #33906] Missing \\ in perlre

Thread Previous
From:
Rafael Garcia-Suarez
Date:
January 24, 2005 02:55
Subject:
Re: [perl #33906] Missing \\ in perlre
Message ID:
20050124115602.2a110ec0@grubert.mandrakesoft.com
Andrew (via RT) wrote:
> 
> In perlre there is a section entitled "Creating custom RE
> engines". The sample code given maps \\ to \ inside regular
> expressions and thus prevents you from using \\ to represent a
> literal \. I think this is unintentional and a patch is included
> below.

Good catch.

> It might also be useful to put in some explanation as to why the
> \\ is required at all as I don't think it is immeadiately clear.
> That said I'm not volunteering to do the writing just now :-/

What about :

    We must also take care of not escaping the legitimate \\Y|
    sequence, hence the presence of '\\' in the conversion rules.

> --- perlre.pod.orig	Tue Jan 13 21:46:44 2004
> +++ perlre.pod	Sun Jan 23 13:31:26 2005

Thanks, applied to the development docs as change #23872.

> @@ -1288,7 +1288,7 @@
> 
>       sub invalid { die "/$_[0]/: invalid escape '\\$_[1]'"}
> 
> -    my %rules = ( '\\' => '\\',
> +    my %rules = ( '\\' => '\\\\',
>   		  'Y|' => qr/(?=\S)(?<!\S)|(?!\S)(?<=\S)/ );

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About