use strict; use POE; use POE::Session; POE::Session->create( inline_states => { _start => \&start, #_start is automagicaly the first event continue => \&looping #user defined event we will call later } ); $poe_kernel->run(); sub start { my ($kernel, $heap, $session) = @_[KERNEL, HEAP, SESSION]; print "Starting in 5!\n"; $kernel->delay( continue => 5 ); # call the continue event in five seconds } sub looping { my ($kernel, $heap, $session) = @_[KERNEL, HEAP, SESSION]; $heap->{counter}++; #the heap is just a hash we can put goodies in. print "$heap->{counter} iteration!\n"; if ($heap->{counter} < 10) { $kernel->delay( continue => 1 ); #start state continue in 1 seconds } }