Correct me if I'm wrong, but the s/// leaves off at the position just after the last replacement ($+[0]). So, if you have
the results is $str = tttTTTT But, if you throw a /g on the end of that, you'll have: $str = ttttttT$str = q{TTTTTTT}; $str =~ s/TTT/ttt/i;
The problem I've been having is that rather than having s/// leave off at $+[0], I was assuming it left off at $-[0] + 1. The difference being, in the example above, with the /g included, the results would be:
This is what I had been hoping for.$str = tttTTTT # after the first replacement $str = ttttTTT # after the second replacement .... $str = ttttttt # after all the global matches are said and done
So, my question becomes, is there a way to set s/// to start looking for replacements at $-[0] + 1 when in a global context, rather than at $+[0]
In reply to Re: s/// only replacing most of the time...
by mdunnbass
in thread s/// only replacing most of the time...
by mdunnbass
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |