in reply to question 1st - undefined behaviour

Another approach is to ask Perl what it thinks about the code you've written (with further reference to perlop):

>perl -wMstrict -MO=Deparse,-p -le "my $x = 5; $x = $x + ++$x + $x++; warn $x; " BEGIN { $^W = 1; } BEGIN { $/ = "\n"; $\ = "\n"; } use strict 'refs'; (my $x = 5); ($x = (($x + (++$x)) + ($x++))); warn($x); -e syntax OK >perl -wMstrict -le "my $x = 5; $x = $x + ++$x + $x++; warn $x; " 18 at -e line 1.

See O and B::Deparse.

Replies are listed 'Best First'.
Re^2: question 1st - undefined behaviour
by rumos2 (Acolyte) on Sep 24, 2013 at 01:22 UTC
    thanks. most complete answer. and no any magic.

      thanks. most complete answer. and no any magic.

      It also doesn't explain the unexplainable :)