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

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

I have a *.pm-File with the line

$chScale = (1 << TSL2561_LUX_CHSCALE);

Textastic prints everything green below the bit-operator <<


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);