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

Re: Expected behavior of \Q inside a bracketed character class?

Thread Previous | Thread Next
From:
Eirik Berg Hanssen
Date:
October 15, 2014 06:22
Subject:
Re: Expected behavior of \Q inside a bracketed character class?
Message ID:
CAHAeAG4r=z1WA0RyxgP4SwSAfoCWThV-BhguHBMKcg7fuqYmvQ@mail.gmail.com
On Wed, Oct 15, 2014 at 7:24 AM, Marco Moreno <mmoreno@pobox.com> wrote:
> Ugh, I meant to say that this returns false instead of true:
>
> perl -e 'print “foo" =~ /[\Qa-z\E]/ ? "true" : "false”'

  Deparse confirms that it quotes the hyphen:

$ perl -MO=Deparse -e 'print "foo" =~ /[\Qa-z\E]/ ? "true" : "false"'
print 'foo' =~ /[a\-z]/ ? 'true' : 'false';
-e syntax OK
$

  ... and yes, this seems to contradict the documentation's "not
usable within a bracketed character class".


Eirik

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