in reply to Weird syntax question

The condition of the if is performed first: $x is false, so it needs the Right hand side of the OR. That prints 0, returns true, and then the if is satisfied (false or true => true). Then it prints 1 because the if said so.

This implies that the or applies to the condition after the if, not to the statement including the if:

print 1 if ($x || print 0)
—John

Replies are listed 'Best First'.
(tye)Re2: Weird syntax question
by tye (Sage) on Aug 23, 2001 at 02:42 UTC

    Good point. Both operands to an "or" are expressions, not statements, so you can't parse "print 1 if $x or print 0" as "( print 1 if $x ) or print 0" since "print 1 if $x" is not a valid expression (since "if" is a statement modifier).

            - tye (but my friends call me "Tye")