in reply to Pre vs Post Incrementing variables

Given my explanation of the problem, the workaround would be to convert the lvalue returns by the pre-increment operator into rvalues.

>perl -E"say ++$i,++$i;" 22 >perl -E"say 0+(++$i),0+(++$i);" 12

Technically, the operand evaluation order for the comma operator in list context is not defined, but it's not likely to ever change, especially since the operand evaluation order for the comma operator in scalar context is defined.

Replies are listed 'Best First'.
Re^2: Pre vs Post Incrementing variables
by JavaFan (Canon) on Sep 13, 2010 at 21:31 UTC
    Technically, the operand evaluation order for the comma operator in list context is not defined,
    The perlop manual page says in the section about the comma operator:
    In list context, it’s just the list argument separator, and inserts both its arguments into the list. These arguments are also evaluated from left to right.
    This has been in perlop since April 2006.