sub replace1{ my $chosen1=$opt1; $t->insert('sel.first',"$chosen1"); $t->delete('sel.first','sel.last'); $t->tagConfigure("replaced",-foreground=>"black"); my $r1=$t->search(-forwards,"$chosen1",'end'); $t->tagAdd("replaced","$r1","$r1 wordend"); #print"\nThe start pos of the pattern:"; #print "\n$result"; }