in reply to s/// only replacing most of the time...
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]
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: s/// only replacing most of the time...
by blazar (Canon) on Jun 05, 2007 at 18:24 UTC | |
Re^2: s/// only replacing most of the time...
by suaveant (Parson) on Jun 06, 2007 at 03:23 UTC |