On Thu, Oct 19, 2006 at 09:56:58AM -0700, Tom Phoenix wrote: > On 10/19/06, Rob Dixon <[EMAIL PROTECTED]> wrote: > > >so the final values of $a and $b are the same regardless and Perl is > >definitely doing something wrongly in the single-line version. > > I would argue that the programmer did something wrongly by abusing the > auto-increment. But don't let that stop you from filing a bug report, > if you wish. > > If you file a bug report and the response is "Well, don't do that, > then", don't say you weren't warned. :-)
And that will be the response. perlop says: Note that just as in C, Perl doesn't define B<when> the variable is incremented or decremented. You just know it will be done sometime before or after the value is returned. This also means that modifying a variable twice in the same statement will lead to undefined behaviour. Avoid statements like: $i = $i ++; print ++ $i + $i ++; Perl will not guarantee what the result of the above statements is. The key to this is what would be called sequence points and undefined behaviour in C. Perl doesn't have the formal concepts of sequence points or undefined behaviour, but in general you should assume it does. The reasons for the observed behaviour are implementation dependent and might change in future releases. Once you know what is happening you will understand why you see the current results (of course), but the behaviour is not obvious without that understanding. Reread Lawrence Statton's replies - he knows what he's talking about. -- Paul Johnson - [EMAIL PROTECTED] http://www.pjcj.net -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>