in reply to Object Methods with POE::Kernel's alarm?

You can use POE::Session's "object_states" rather than (or in addition to) "inline_states". The following example will have $object handle three events: "_start" will trigger its handle_start() method, "tick" will call handle_tick() and "tock" will call handle_tock():

my $object = Object->new(); POE::Session->create( object_states => [ $object => { _start => "handle_start", tick => "handle_tick", tock => "handle_tock", }, ], );

Here are their hypothetical handlers. Note that we're using POE::Kernel's delay() method here. delay() is equivalent to what you're doing with alarm():

sub handle_start { $_[KERNEL]->delay( tick => 1, 0 ); }, sub handle_tick { my ($self, $kernel, $count) = @_[OBJECT, KERNEL, ARG0]; print "tick $count\n"; $self->do_other_stuff(); $kernel->delay( tock => 1, $count + 1 ); }, tock => sub { print "tock $_[ARG0]\n"; $_[OBJECT]->do_more_stuff(); $_[KERNEL]->delay( tick => 1, $_[ARG0] + 1 ); },

Important note: OBJECT is a constant that evaluates to $self's position within @_ (almost always zero). If a program executes my $self = shift; it will shift everything in @_ one element closer to zero. All the other constants (such as KERNEL and ARG0) would then be pointing to the wrong values within @_.