tom arnall wrote:
> from the debugger:
> 
>       p 1 if /[\Q$\E]/
>       
> gets:
> 
>       Unmatched [ in regex; marked by <-- HERE in m/[ <-- HERE E\]/ 
> 
> the following works:
> 
>       p 1 if /[\Q\$\E]/
> 
> but shouldn't \Q \E be sufficient to make perl treat '$' as a literal?

No, interpolation of variables happens before the escape sequences so that the
contents of the variables can be quotemeta()ed:

$ perl -le' $x = q[A.C]; $y = qr[\Q$x\E]; print $y'
(?-xism:A\.C)
$ perl -le' @x = qw[A . C]; $y = [EMAIL PROTECTED]; print $y'
(?-xism:A\ \.\ C)

By default the $\ variable contains the string "\n":

$ perl -le' $y = qr[\Q$\E]; print $y'
(?-xism:\
E)

So after the variable is interpolated that is seen as /\Q\nE/.



John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to