in reply to Re: "2" | "8" = ":" and 2|8=10
in thread "2" | "8" = ":" and 2|8=10
BTW This difference does not fit into the philosophy of Perl, where you should not be able to distinguish between strings and numbers, so this is actually a language design flaw.
Agreed. Perl always had the philosophy that the operators determine the operation, not the type of the operands. Perl 6 solves this by adding type modifiers for the bitwise operators:
$a +| $b; # Integer bitwise OR $a ~| $b; # String bitwise OR $a ?| $b # logical OR
It makes the bitwise operators look a bit more ugly, but I don't really mind because I don't use them very often. This change has the additional benefit of freeing up the characters that perl 5 uses for bitwise operators.
(Note that || as a logical OR still exists; the difference is that || returns the first true value, whereas ?| always returns a Bool).
|
|---|