# insert widget code here open (LOG, "log.log") || die "Nope : $!"; load_file(5); $mw->repeat(5000,\&tail_file); # check every 5 seconds MainLoop(); sub load_file { my $n = shift || 10; #how many lines to initially tail my @tail; while(){ shift @tail if $#tail > $n; push @tail, $_; } for(@tail){ if(/(CRITICAL|MAJOR)/){ $text->insert('end',$_,$1); } else { $text->insert('end',$_); } } } sub tail_file { seek(LOG,0,1); while(){ if(/(CRITICAL|MAJOR)/){ $text->insert('end',$_,$1); } else { $text->insert('end',$_); } } }