[TxMt] Re: bug in syntax highlighting?

Hans-Jörg Bibiko bibiko at eva.mpg.de
Tue Nov 8 19:57:31 UTC 2011


On 8 Nov 2011, at 20:38, Thomas Blom wrote:

> I was trying to figure out why the syntax highlighting in perl sucked so much, when I realized it was getting messed up by some regex code.  
> 
> Paste this into file (e.g. test.pl) and view in textmate.  Does the 2nd function hilight correctly?  It is the /\\/ regex I think - comment the first one out and watch the hilighting change.
> 
> sub fn() {
> 	# some perl code
> 	my $f = shift;
> 	if( $f =~ /\\/ ) { 
> 		my $var = "Hello";
> 	}
> }
> 
> sub fn2() {
> 	# some perl code
> 	my $f = shift;
> 	if( $f =~ /\\/ ) { 
> 		my $var = "Hello";
> 	}
> }


Hi Thomas,

syntax highlighting for Perl is not so easy but in that case you can fix the highlighting if you simply make usage of the "standard" syntax in the if clauses:

	...
	my $f = shift;
	if( $f =~ m/\\/ ) { 
	....


write m// instead of // .

Cheers,
--Hans


More information about the textmate mailing list