Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

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]
[Happy-the-monk]: marto: like not coming back to it until the following day would be my advise to myself.
[marto]: Happy-the-monk very wise

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2018-03-18 18:12 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (230 votes). Check out past polls.