Date: | Sat, 29 Nov 2003 04:38:25 -0500 |
From: | Apocalypse <apocalypse [...] 0ne.us> |
To: | bug-POE [...] rt.cpan.org |
Subject: | POE::Wheel::ReadLine not working perfectly |
The program will simply wait until I pressed two keys, then somehow lock
up doing select()'s all over the map...
Using POE's TRACE_DEFAULT method, I was unable to pinpoint the error,
other than seeing the select's scroll up the screen
after pressing a second key...
I've reduced the problem to this minimal program:
# Standard stuff to catch errors
use strict qw(subs vars refs); # Make sure we can't mess up
use warnings FATAL => 'all'; # Enable warnings to catch
errors
# Turn on extensive debugging
sub POE::Kernel::ASSERT_DEFAULT () { 1 }
sub POE::Session::ASSERT_STATES () { 1 }
sub POE::Kernel::TRACE_DEFAULT () { 1 }
# Use POE!
use POE;
use POE::Wheel::ReadLine;
# Create the session
POE::Session->create(
'inline_states' => {
'_start' => \&SetupWheel,
'_stop' => sub {},
'Got_Input' => \&GotInput,
},
);
POE::Kernel->run;
# Setup the wheel
sub SetupWheel {
my $heap = $_[ HEAP ];
# Create the wheel.
$heap->{wheel} = POE::Wheel::ReadLine->new( InputEvent => 'Got_Input' );
# Trigger the wheel to read a line of input.
$heap->{wheel}->get( 'Prompt: ' );
}
# Input handler. If $input is defined, then it contains a line of
# input. Otherwise $exception contains a word describing some kind
# of user exception. Currently these are 'interrupt' and 'cancel'.
sub GotInput {
my ($heap, $input, $exception) = @_[HEAP, ARG0, ARG1];
if (defined $input) {
$heap->{wheel}->put("\tGot: $input");
$heap->{wheel}->get('Prompt: '); # get another line
} else {
$heap->{wheel}->put("\tException: $exception");
}
}
--
Apocalypse
Homepage: http://JiNxEdStAr.0ne.us
IRC: Apocalypse@irc.perl.org
IRC: Apocal@EFnet
CPAN ID: APOCAL