Re: Increment Operator (++) question in Perl

2009-11-03 Thread John W. Krahn
Majian wrote: Hi ,all: Hello, When I test the increment operator in Perl and find a question : The question is : #!/usr/bin/perl use warnings; my $i = 1; print ++$i + ++$i, "\n"; The above code prints out the answer 6 . But in the other language the anser is 5 , And the lesson t

Re: Increment Operator (++) question in Perl

2009-11-03 Thread Paul Johnson
On Tue, Nov 03, 2009 at 07:15:43PM +0800, Majian wrote: > Hi ,all: Hello, > When I test the increment operator in Perl and find a question : > > The question is : > #!/usr/bin/perl > use warnings; > > my $i = 1; > print ++$i + ++$i, "\n"; > > The above code prints out the answer 6 . >

Re: Increment Operator (++) question in Perl

2009-11-03 Thread Philip Potter
2009/11/3 Majian : > Hi ,all: > >  When I test the increment operator in Perl and  find   a question : > > The question is : > #!/usr/bin/perl > use warnings; > > my $i = 1; > print  ++$i  + ++$i, "\n"; > > The above code prints  out  the answer 6 . > But in the other language  the anser is 5 , > >

Re: Increment Operator (++) question in Perl

2009-11-03 Thread Erez Schatz
2009/11/3 Majian : > > my $i = 1; > print  ++$i  + ++$i, "\n"; > > The above code prints  out  the answer 6 . > But in the other language  the anser is 5 , > >From the documentation (http://perldoc.perl.org/perlop.html#Auto-increment-and-Auto-decrement): "Note that just as in C, Perl doesn't defi