in reply to Re^2: Change variable multiple times within a single string?
in thread Change variable multiple times within a single string?
That is not correct! The value of the variable $yes_or_no will only be changed on the occurrence of 'A' or 'B' in the string. That is what if exists $decision{$_}; is for, there is no entry of for '1' in the hash.
Printing the variable in each line is only showing the current value. The OP had not really said what he wanted to do while running through the string, so I made something up.
In a way, the print statement is completely superfluous, as the script would set the variable according to the wishes of the OP, but it would not be observable...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Change variable multiple times within a single string?
by 2teez (Vicar) on Apr 27, 2013 at 18:09 UTC |