In mathematics (i.e. boolean algebra) it is common to denote * for and and + for or IFF the alphabet is restricted to boolean values 0 and 1.
NOTE: 1 + 1 is mapped to 1 there.
This works in Perl somehow. (1+1 =2 is still true)
But don't ! It's not recommended ... rather a workaround in languages without boolean operators.²
Just sketch the truth table to see how it works.
Better use && and || instead.
> Y = (A & B)
that's definitely wrong, because & is for a bitwise and not a logical.
UPDATE
to elaborate more: the standard false value in Perl is not 0 but empty string '' . While the latter will be evaluated to 0 in arithmetic operations it might cause a confusion.
DB<7> print !!0
DB<8> print !!1
1
footnotes
²) and only for simple cases, b/c you risk a number overflow when multiplying true values.
> perl -E "say ((1+1) * (1+1) * (1+1));"
8
|