To: beginners@perl.org Date sent: Thu, 19 Oct 2006 13:55:45 +0200 From: Norbert Preining <[EMAIL PROTECTED]> Copies to: Elisa Mori <[EMAIL PROTECTED]>, [EMAIL PROTECTED] Subject: Evaluation of ++ different in C and perl?
> Hi all! > Maybe this has been answered before, but my searching didn't show up > anything: The Perl Book says: Auto increment and decrement work as in > C. So if I take this C program: #include <stdio.h> #include <stddef.h> > int main() { > int a; > int b; > a=3; > b=(++a)+(a++); > printf("b=%d\n",b); > } > it prints b=8. > > When I do the same in perl: > $a = 3; > $b = (++$a) + ($a++); > print "b=$b\n"; > > It prints b=9. > > I checked with a friend and Java behaves like C and prints 8. > > Can someone enlighten us by giving an interpretation of the above > term? Anyone who uses something like that begs for problems. Just don't do that. Jenda ===== [EMAIL PROTECTED] === http://Jenda.Krynicky.cz ===== When it comes to wine, women and song, wizards are allowed to get drunk and croon as much as they like. -- Terry Pratchett in Sourcery -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>