use English; use strict; use warnings; use Data::Dumper; use Tk; use POE; my $TXT; # Create file descriptor from input file name... my $infile = shift || die "Missing input file"; open(IFILE, "<$infile") || die "Cannot open $infile: $!"; my $IN = *IFILE{IO}; my $session = POE::Session->create( inline_states=>{ _start=>sub { $TXT = $poe_main_window->Scrolled('Text')->pack; $poe_main_window->update; $poe_main_window->fileevent ( $IN , 'readable', sub { _GetInput($IN) } ); }, }, ); # Create a dummy postback so the session won't die... my $subref = $session->postback('DontDie'); $poe_kernel->run(); sub _GetInput { my $ifile = shift || die "Missing File Descriptor"; if(eof($ifile)) { $poe_main_window->fileevent($ifile, 'readable', ''); return; } my $line = <$ifile> || die "Cannot read $!"; print STDERR $line; $TXT->insert('end', $line); $TXT->update; sleep 1; }