The Perl boolean operators like &&
, ||
, and
, or
don't return a boolean value, they return the value of one of their arguments:
say 2 && 3;
outputs 3
.
You can force it to a boolean with the double negation trick:
say !!(2 && 3);
# or
say not not 2 && 3;
outputs 1
.