my $word = '#'; my $next = "1.0"; while (my $from = $t->search(-regexp, "\\B$word\\B", $next, "end")) { my @comment = split(/#/, $_); #print "\$comment[0] equals ",$comment[0],"\n"; #print "\$comment[1] equals ",$comment[1],"\n"; if ($comment[1]) { my $word_len = length $comment[1] + length $word; }else{ my $word_len = length $comment[0] + length $word; } print $word; print $word_len; $next = "$from + $word_len chars"; $t->tagAdd("orange", $from, $next); $t->tagAdd("bold", $from, $next); }