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 | [reply] |
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?
| [reply] |
You won't be able to shield yourself from the user's magic.
You got to get the value of variable, and if it has get-magic,
it's magic will be triggered, whether you put the value in a
tmp variable, or in an expression. Furthermore, at the end,
you're going to put the value back, so any set-magic will be
triggered. Regardless whether you used a temp variable in between. But even if there's a way to avoid magic (in some
cases, the use of temp variables can circumvent overload magic), in general you shouldn't. The user put that magic there for some reason (persistency, for instance), and would
not expect a module to go out of its way to avoid it.
Abigail
| [reply] |