The issue is with the "if" statement checking to see if $_ matches a # character. I thought I could reference $_ while the "search" function of the "Scrolled" widget was being traversed but it appears that $_ is empty during this process so of course it will never match a # character. Anyone know what this search function references as the current string so I can implement this?@words = ("print", "sprintf"); foreach my $word (@words) { my $word_len = length $word; my $next = "1.0"; while (my $from = $t->search(-regexp, "\\b$word\\b", $next +, "end")) { $next = "$from + $word_len chars"; if ($_ =~ /\#/) { my @comment = split(//, $_); my $i = 0; foreach my $comment (@comment) { if ($comment eq "#") { my $offset = $i; if ($from < $offset) { $t->tagAdd("red", $from, $next); } }else{ $i++; } } }else{ $t->tagAdd("red", $from, $next); $t->tagAdd("bold", $from, $next); } } }
In reply to $_ is null in Tk:Scrolled search? by Elijah
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |