in reply to '||' vs 'or' with subroutines

Roy Johnson and hardburn are both wrong. Both || and or impose scalar context on their left operand. The difference is that or has a lower precedence than = so between the two forms, only the one using or was written correctly.

@foobar = foo() || warn;

@foobar = ( scalar( foo() ) || warn );

@foobar = foo() or warn;

scalar( @foobar = foo() ) || warn;

Replies are listed 'Best First'.
Re^2: '||' vs 'or' with subroutines
by sweetblood (Prior) on Nov 11, 2004 at 16:01 UTC
    Yes, that clears it up. An excellent example++.

    Thanks!

    Sweetblood