Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Operator Associative in Perl

by lakshmananindia (Chaplain)
on Jun 03, 2009 at 11:02 UTC ( [id://767971]=note: print w/replies, xml ) Need Help??


in reply to Operator Associative in Perl

From man perlop

Note that just as in C, Perl doesn't define when the variable is incremented or decremented. You just know it will be done sometime before or after the value is returned. This also means that modifying a variable twice in the same statement will lead to undefined behaviour. Avoid statements like:

$i = $i ++; print ++ $i + $i ++;

Perl will not guarantee what the result of the above statements is.

--Lakshmanan G.

The great pleasure in my life is doing what people say you cannot do.


Replies are listed 'Best First'.
Re^2: Operator Associative in Perl
by ikegami (Patriarch) on Jun 03, 2009 at 15:24 UTC

    Perl doesn't define when the variable is incremented or decremented. [...] Perl will not guarantee what the result of the above statements is.

    While operand evaluation order isn't documented, the order is the same in all versions on all platforms (intentionally), and changing it would break a lot of code.

    perl always evaluates operands from left to right for left-associative operators and exponentiation (**), and from right to left for assignments operators.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2024-03-19 02:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found