Tk has a function built in called
fileevent that is made for stuff like this.
Here's an example pretty much right out of "Learning Perl/Tk" from O'Reilly.
use Tk;
my $mw = MainWindow->new();
my $text = $mw->Scrolled("Text",
-width => 80,
-height => 25)->pack(-expand => 1);
$mw->fileevent(STDIN, 'readable', [\&insert_text]);
MainLoop;
sub insert_text
{
my $curline=<STDIN>;
$text->insert('end', $curline);
}
That seems to work very nicely with a tail command piping output to the script. The other option of course, would be to open
tail as a filehandle, like:
open(FH,"tail -f -n 1 logifle") || die "Could not tail: $!";
Then use
<FH> instead of
<STDIN> in the above.
P.S.
My wife now hates you, I've often wondered how to do similar things it Tk, but never had a driving need. Now that I looked up an answer to your question, I might just start messing around with Tk again (I can see lots of possibilites!)