in reply to Re: Variable assignment after logical OR
in thread Variable assignment after logical OR

In your open statement, || is evaluated before the comma, so your statement is parsed as open FILE, (">test.txt" || $failed_flag = 1); giving the syntax error.

Actually the  || operator also has higher precedence than the  = operator so it is parsed as open FILE, (">test.txt" || $failed_flag) = 1; which is why you get the error  Can't modify constant item in scalar assignment

Replies are listed 'Best First'.
Re^3: Variable assignment after logical OR
by FunkyMonk (Bishop) on Oct 02, 2007 at 20:40 UTC
    You're absolutely right of course and I should have noticed that. Thanks for pointing it out.