use POE qw(Loop::Tk); POE::Session->create( inline_states => { _start => sub { $_[KERNEL]->yield("next") }, next => sub { print "tick...\n"; $_[KERNEL]->delay(next => 1); }, }, ); $button = $poe_main_window->Button( -text => 'Press me', -command => sub { exit; }, )->pack(); $poe_kernel->run();