develooper Front page | perl.perl5.porters | Postings from March 2000

Re: [ID 20000323.013] @a not protected by \Q in re

Thread Previous
From:
Tom Christiansen
Date:
March 23, 2000 05:20
Subject:
Re: [ID 20000323.013] @a not protected by \Q in re
Message ID:
18318.953817636@chthon
>\Q does not protect @foo in rexen.  This seems to me to be an issue,
>given that I use \Q to reduce gotchas in user-supplied REs.  Should
>it not do this?

No, it should not do this.  Its "protection" occurs after interpolation,
as this should illustrate:

    % perl -Mstrict -we 'my $x = "th.?is"; printf "%d\n", $x =~ /$x/'
    0
    % perl -Mstrict -we 'my $x = "th.?is"; printf "%d\n", $x =~ /\Q$x/'
    1
    % perl -Mstrict -we 'my $x = "th.?is"; printf "%d\n", $x =~ /\Q$z/'
    Global symbol "$z" requires explicit package name at -e line 1.
    Execution of -e aborted due to compilation errors.
    Exit -1

--tom

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