> > > > > $x=10; > > > > $x=$x++; > > > > print "$x\n"; > > > > $x=10; > > > > $y=$x++; > > > > print "$x\n"; > > > > #Results: $x=10, $x=11. > > #I understand it, but I think it's weird anyway. > > > > The first result ($x=10) puzzles me. Are not the $x on the > LHS and RHS > refering to the same scalar? I would think that $x would be > assigned the > value of $x (10), and then be post-incremented, resulting in 11. > > Explanation? >
It would seem that setting the variable takes precedence over the post-increment. Note that if you pre-increment, i.e. $x=++$x you get the expected result. It's like perl's internals does something like this... $temporaryvalue = $x; $x++; $x = $temporaryvalue; return $x; My guess is that the post increment actually does happen internally but is then overwritten. Anyone know for sure? An interesting little finding... _______________________________________________ Perl-Win32-Users mailing list [email protected] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
