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.
Yep. Thats what I tried to say myself, but youv'e done a much better job. :-)
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.
Yep, its just that Perls loose rules for this stuff make it so easy to do. Given enough rope to hang themselves... :-)
In reply to Re: Re: Order of operations, mutators, aliasing and whammies
by demerphq
in thread Order of operations, mutators, aliasing and whammies
by demerphq
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |