Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Re: question 1st - undefined behaviour

by Riales (Hermit)
on Sep 23, 2013 at 22:03 UTC ( #1055392=note: print w/replies, xml ) Need Help??

in reply to question 1st - undefined behaviour

I think the first and second $x would be 6 actually, due to the prepend happening on the second $x.

Here are the steps in order:

1. ++$x: All $x are now 6.

2. 6 + 6 + 6

3. $x++: All $x are now 7.

4. $x = 18: The value from the 6 + 6 + 6 is assigned to $x.

Replies are listed 'Best First'.
Re^2: question 1st - undefined behaviour
by rumos2 (Novice) on Sep 23, 2013 at 22:21 UTC
    sorry if I making a mistake, but looks like you are wrong - why - try understand why
    my $x=5; $x=++$x + $x++ + $x; warn $x;
    return's 20.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1055392]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (9)
As of 2018-06-20 14:34 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (116 votes). Check out past polls.