--- "Dr.Ruud" <[EMAIL PROTECTED]> wrote:

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


Lessons learned....

always initialize your variables to zero. : )


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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