Help for this page

Select Code to Download


  1. or download this
    $string = "pre replace post";
    $i = 4;
    $j = 11;
    $length = $j - $i;
    substr($string, $i, $length) = "x" x $length;
    print "$string\n";
    
  2. or download this
    $string = "pre replace post";
    $i = 4;
    $j = 11;
    substr($string, $i, $j - $i) =~ tr/x/x/c;
    print "$string\n";