# insert widget code here open (LOG, "tail -f log.log|") || die "Nope : $!"; $mw->fileevent(\*LOG, 'readable', \&insert_lines); MainLoop(); sub insert_lines { my $line; if(defined($line = )){ if( $line =~ /(CRITICAL|MAJOR)/){ $text->insert('end',$line,$1); } else { $text->insert('end',$line); } }else{ $mw->fileevent(\*LOG, 'readable',''); } } #### # 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',$_); } } }