[This feature is no longer experimental, starting in v5.28. Declaring use 5.28
automatically enables them.]
Most Perl operators force their context on the values. For example, the numeric addition operator, +
, forces its values to be numbers. To “add” strings, you use a separate operator, the string concatenation operator, .
(which looks odd at the end of a sentence).
The bitwise operators, however, look at the value to determine their context. With a lefthand value that has a numeric component, the bitwise operators do numeric things. With a lefthand value that’s a string, the bit operators become string operators. That’s certainly one of Perl’s warts, which I’ll fix at the end of this article with a new feature from v5.22. Continue reading “Make bitwise operators always use numeric context”