in reply to Re: another tricky one from lol
in thread another tricky one from lol

substr is lvaluable:
$string = "pre replace post"; $i = 4; $j = 11; $length = $j - $i; substr($string, $i, $length) = "x" x $length; print "$string\n";
Or to avoid using $length twice:
$string = "pre replace post"; $i = 4; $j = 11; substr($string, $i, $j - $i) =~ tr/x/x/c; print "$string\n";
But that's probably gratuitous obfuscation.