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

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.


Comment on Re: question 1st - undefined behaviour
Select or Download Code
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?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1055392]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2015-07-30 03:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (269 votes), past polls