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

Re: qr'$foo' and unescaped $ signs

Thread Previous | Thread Next
From:
Karl Williamson
Date:
June 30, 2021 13:12
Subject:
Re: qr'$foo' and unescaped $ signs
Message ID:
2e70b55b-e16f-8bea-5ba0-2ada5b24486c@khwilliamson.com
On 6/30/21 6:22 AM, Nicholas Clark wrote:
> On Wed, Jun 30, 2021 at 06:18:13AM -0600, Karl Williamson wrote:
> 
>> $ blead -Dr -le "qr'$foo'm"
>> Compiling REx ""
>> Final program:
>>     1: NOTHING (2)
>>     2: END (0)
>> minlen 0
>> Enabling $` $& $' support (0x7).
> 
> I think that your Unix shell quoting is not doing you favours here.
> 
> I think that for this examples the shell will replace $foo with an empty
> string, as the shell is processing the "" quotes. So you perl one-liner
> is not what you intended. (I believe).
> 
> And in the other, \$ is processed by the shell, not perl's parser.
> 
> Nicholas Clark
> 

Sorry.  Hopefully this is better

§ cat nwc.pl
qr'$foo'm;
qr'\$foo'm;

§ blead -Dr nwc.pl
  Compiling REx "$foo"
  Final program:
     1: MEOL (2)
     2: EXACT <foo> (4)
     4: END (0)
  anchored "foo" at 0..0 (checking anchored) minlen 3
  Compiling REx "\$foo"
  Final program:
     1: EXACT <$foo> (3)
     3: END (0)
  anchored "$foo" at 0..0 (checking anchored isall) minlen 4
  Enabling $` $& $' support (0x7).


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