Tom writes: > I'm not sure whether C does so, but I believe that Perl does NOT > promise that auto-increments will be executed in the "expected" > left-to-right order. Thus, if a single expression includes more than > one auto-increment working on the same variable, generally you can't > be sure what Perl will do with it. As you found.
In the C standard, the behaviour for int a = 1, b; b = ++a + a++; is *undefined*. Perfectly standards-compliant C compilers can perform any of the following actions with equal validity: * the compiler can dump core, and produce no output. * at run time, the program can halt printing "Do not be a loser!" * it can return "42" * it can return '2' (1 + 1) and then increment a twice. * it can - through blind stupid luck - return 5 See the comp.lang.c faq Questions 3.2 et seq. and comp.lang.c faq question 11.33 Short answer: In C, Don't Do That. By extension, don't do it in Perl. -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- Lawrence Statton - [EMAIL PROTECTED] s/aba/c/g Computer software consists of only two components: ones and zeros, in roughly equal proportions. All that is required is to sort them into the correct order. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>