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


in reply to Operator Associative in Perl

Basically what you are saying is, "give me the value of $a, increment it sometimes afterwards", "give me the value of $a, decrement it sometimes afterwards", "give me the value of $a but only after you've incremented it", "give me the value of $a, but only after you've decremented it". Note that you never say at which moment the value of $a needs to change, just that it needs changing sometime before (or after) fetching the value.

Getting 56555 is not unreasonable. But another result wouldn't have been unreasonable either. In general, it's a bad idea to use ++ or -- twice on the same variable in the same statement is a bad idea. Or to assign to a variable in the same statement as you apply ++ or -- to that variable.

Replies are listed 'Best First'.
Re^2: Operator Associative in Perl
by catellus (Initiate) on Jun 04, 2009 at 17:24 UTC
    JavaFan said:
    >In general, it's a bad idea to use ++ or -- twice on the >same variable in the same statement is a bad idea.

    The paralell of the repitition in the sentence to the original topic gave me quite a chuckle. I hope it was intentional.

      It wasn't intentional, but it does stress it's a bad idea. ;-)