in reply to Matching and order of evaluation

None of that should be a problem. You could get problems if you modify a variable twice between sequence point, but using it on both sides of an assignment should be fine (usually). Your example isn't very different from:
$var = $var + 1;

Abigail

Replies are listed 'Best First'.
Re: Re: Matching and order of evaluation
by diotalevi (Canon) on Oct 27, 2003 at 21:28 UTC
    I thought that it was a simple statement but wasn't sure. In fact, I don't know whether your simple example is safe for all $var - does it become unsafe if $var has get-magic or set-magic?
      Well, if there's magic involved, anything could happen - after all, you're then back into "user" land. But, assuming nothing weird happens during the magic, it should be fine. The order will be: FETCH, evaluate RHS expression, STORE.

      Abigail

        So then, so that I'm clear - if I control the input and know its going to be mundane perl then I can do what I've always done ($x = $x + 1) but if I'm writing module code that accepts input from the user then I've got to be pessimistic and use a temp variable or something to shield myself from the user's magic?