Doesn't run under activestate?
Craig Votava <[email protected]>
| Newsgroups | gmane.comp.lang.perl.poe |
|---|---|
| Message-ID | <[email protected]> |
Folks-
I would like to add something like this to the POE cookbook, but this
version won't run under activestate. Any pointers on what I'm doing
wrong? This is also part of a discussion at http://www.perlmonks.org/?node_id=775719
.
Thanks
-Craig
use English;
use strict;
use warnings;
use Tk;
#use POE;
use POE(qw(Loop::TkActiveState));
# Create file descriptor from input file name...
my $infile = shift || die "Missing input file";
open(IFILE, "<$infile") || die "Cannot open $infile: $!";
my $ifd = *IFILE{IO};
my $TXT;
my $session = POE::Session->create(
inline_states=>{
_start=>sub {
$TXT = $poe_main_window->Scrolled('Text')->pack;
$_[KERNEL]->select_read($ifd, '_GetInput');
},
_GetInput=>sub {
if (my $line = <$ifd>) {
print STDERR $line;
$TXT->insert('end', "-$.- $line");
$poe_main_window->update;
} else { $_[KERNEL]->select_read($ifd) };
},
},
);
# Create dummy postback so the session won't die once input is done...
my $subref = $session->postback('DontDie');
# Go...
$poe_kernel->run();