http://www.perlmonks.org?node_id=495986


in reply to True or False? A Quick Reference Guide

bobf++, well done.

There is another logical operator; I like to regard the sequence operator, scalar comma, as the unconditional logical operator. The right hand argument is evaluated regardless of the truth of the already-evaluated left, and the last evaluated value is returned. Naturally, this has more use in shoehorning several evaluations into a single expression than in pure logic. It's often useful that way in the body of modifier statements like s/foo/bar/g, print for <>;.

Used where logicals are often seen, sequence expressions can be a sort of front-loaded continue block - without introducing a scope.

my ($i, $j) = (1, 10); while ($i++, $j--, $i < $j) { print "$i\t$j\n"; } __END__ 2 9 3 8 4 7 5 6
Note that increment and value of a variable in one expression are ok with C if they are seperated by the comma operator. That seems to work in Perl, too, as is sort-of-documented.

I think that that view of the sequence operator is not the usual one, but I find it useful. If there were an ultra-low precedence version like and and or, I'd call it then.

After Compline,
Zaxo