sub check_cond { my $callback = shift; my $kernel = shift; my $session = shift; my $result = $callback->(); if ($result) { $kernel->post( $session, event => @_ ); } return $result; } # then check_cond(sub { 2 > 1 }, $kernel, $session, @args) and return;