0

Perl: Bit Operator "<<" is interpreted as #

Stefan Theurer 9 years ago in General updated by Alexander Blach (Developer) 9 years ago 1

I have a *.pm-File with the line


$chScale = (1 << TSL2561_LUX_CHSCALE);


Textastic prints everything green below the bit-operator <<


Image 135


Hello,


in Perl, "<<" can start a heredoc string.


While the Perl interpreter can decide if this is indeed a Heredoc string or a shift left operator, a simple language grammar can't, because it doesn't know that TSL2561_LUX_CHSCALE is a constant.


If you save the constant in a variable first and use that to do the binary left shift, it is highlighted correctly:


$shift = TSL2561_LUX_CHSCALE;
$chScale = (1 << $shift);