Norbert Preining schreef:

> 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.

$ perl -wle '
  $a = 3;
  $b = 0 + (++$a) + ($a++);
  print "b=$b\n";
'
b=8
:)

-- 
Affijn, Ruud

"Gewoon is een tijger."

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to