in reply to Order of operations, mutators, aliasing and whammies
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Order of operations, mutators, aliasing and whammies
by demerphq (Chancellor) on Sep 04, 2003 at 23:19 UTC | |
|
Re: Re: Order of operations, mutators, aliasing and whammies
by asarih (Hermit) on Sep 05, 2003 at 18:04 UTC | |
by Abigail-II (Bishop) on Sep 05, 2003 at 21:31 UTC | |
by Jenda (Abbot) on Sep 09, 2003 at 12:01 UTC | |
by Abigail-II (Bishop) on Sep 09, 2003 at 12:25 UTC | |
by Jenda (Abbot) on Sep 09, 2003 at 14:05 UTC | |
|