[TxMt] Bug in perl syntax?

Allan Odgaard throw-away-1 at macromates.com
Fri Feb 16 06:41:40 UTC 2007


On 15. Feb 2007, at 19:00, Grant Hollingworth wrote:

> [...]
>> But now let’s use / as delimiter instead:
>>
>>    my $foo = qr/test $//;
>>
>> This is ambiguous.
>
> It's not ambiguous.  The end delimiter is the first non-escaped  
> character that matches the start delimiter.  Perl finds the end  
> delimiter and then realizes that the $ must be an end-of-line  
> marker.  When using slashes as the delimiter, you have to write $/  
> as $\/.
>
> In this case the variable pattern doesn't know that $/ isn't a  
> valid variable name.  Do we have to recreate the variable pattern  
> instead of importing it?

You can’t import it, but you can’t recreate it either, as you  
wouldn’t know what character to escape (and thus not allow as the  
first character of a variable).

But we can recreate a limited variable pattern that just disallows  
all the potential delimiter characters as the first character of a  
variable -- I guess that in practice, no-one would notice, and at  
least examples like from the OP won’t render the rest of the line/ 
document still inside the regexp.




More information about the textmate mailing list