In your example, s// is modifying $data twice within one statement.
Could it be that, as a general rule, the results of modifying a variable twice in a statement is unspecified? This might explain the Perl implementation dependent behavior discussed above. It certainly seems to be the case for the increment and decrement operator. Perhaps it is also true for s// and other operators that modify the variable upon which they operate? As stated in perlop (I've bolded the key words):
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.
Best, beth
In reply to Re: two regexes in one function call
by ELISHEVA
in thread two regexes in one function call
by bobr
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |