# conceptually, the following is like $a=~s/$b/$c/, but is safe if $b has metacharacters in it sub string_substitution_one { my $a_ref = shift; my $b = shift; my $c = shift; my $a = $$a_ref; my $debug = ($b eq '$m$'); my $i=index($a,$b); return 0 if $i == -1; my $z = ''; if ($i>0) {$z = $z . substr($a,0,$i)} $z = $z . $c; if ($i+length($b)