Now this behaviour confused me. Why should the extra meaningless subtraction affect the order of operations?
Well, that's easy. You have more operations! Of course things will change. ;-)
Without the subtraction, all perl needs to do is remember where the value of $ofs is, and get it when it's time to output the resulting string. Of course, in between, the value gets modified. With the subtraction, perl gets the value of $ofs, subtract 0, and scribbles away the result. That result won't get modified when $ofs gets modified.
Don't modify a variable and use its value elsewhere in the same expression. Don't modify a variable twice in the same expression. Don't assume Perl has a defined order of evaluation.
Abigail
In reply to Re: Order of operations, mutators, aliasing and whammies
by Abigail-II
in thread Order of operations, mutators, aliasing and whammies
by demerphq
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |