lolly has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's minimum standard of quality and will not be displayed.

Replies are listed 'Best First'.
Re: another tricky one from lol
by particle (Vicar) on Apr 19, 2002 at 12:15 UTC
Re: another tricky one from lol
by Biker (Priest) on Apr 19, 2002 at 11:31 UTC

    Show us the code you have written so far, lolly. And indicate the specific problem(s) you have in it.


    Everything went worng, just as foreseen.

Re: another tricky one from lol
by csotzing (Sexton) on Apr 19, 2002 at 12:54 UTC
    I'm not sure exactly what your doing, but could you just use substr? I wrote a small sample below that outputs "pre XXXXXXX post"
    $string = "pre replace post"; $i = 4; $j = 11; $length = $j - $i; $result = substr($string,0,$i) . "x" x $length . substr($string,$j); print "$result\n";
      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.
A reply falls below the community's threshold of quality. You may see it by logging in.