Pathologically Eclectic Rubbish Lister | |
PerlMonks |
Re^2: question 1st - undefined behaviour (perlop)by rumos2 (Acolyte) |
on Sep 23, 2013 at 23:30 UTC ( [id://1055405]=note: print w/replies, xml ) | Need Help?? |
I've mean exactly this - my $x=5; my $y=$x + ++$x; $y returns 12. here $x in first position is used as original $x and it's returns it's changed value after calculation of pre-increment. my $x=5; my $y=$x + ++$x + $x++ $y returns 18. precedence crash(5($x) + 7(++$x is 6, but returns $x and become 7 after next step) + 6($x++, at now $x is 7, but here we get copy before increment and get 6) in this order) or $x is used as a copy at here (like after $x++) and this copy is maked BEFORE any changes. my $x=5; my $y=++$x + $x++ + $x $y returns 20 - ++$x return $x and make it's value 6; $x++ return 6 forever, but $x is 7 at now 7 + 6 + 7 == 20 - ok.
In Section
Seekers of Perl Wisdom
|
|