| Refresh | Home EGTry.com

simple string replacement without regex expression


substr($text, $fromIndex, $length)=$replacement

use strict;

my $orig="the fixed string replacement";

my @words=qw(the fixed string replacement);

foreach my $word (@words) {
  my $index=index($orig, $word);
  if ($index >-1) {
    substr($orig, $index, length($word))=$word . $word;
  }
}
print $orig;