[TxMt] Bug in perl syntax?

Grant Hollingworth grant at antiflux.org
Thu Feb 15 18:00:15 UTC 2007


* Allan Odgaard <throw-away-1 at macromates.com> [2007-02-15 10:47]:
>Actually not, i.e. the following works fine:
>
>    my $foo = qr$allan$;
>
>What fails is using $ in a regexp where it looks like a variable but  
>is actually not.

Right, as in:

  my $foo = qr!allan$!;

TextMate thinks that it's the variable $! instead of end-of-line followed by regexp delimiter.  That's what I meant by the variable pattern having precedence.

>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?



More information about the textmate mailing list