http://www.perlmonks.org?node_id=511869

BUU has asked for the wisdom of the Perl Monks concerning the following question:

Here's the scenario. I have an event handle that, based on certain conditions, should send an event to another session with specific arguments, and then exit the current subroutine. The perl implementation is simple:
if( $condition ) { $kernel->post( $s, event => @args ); return; }
The problem is, I want to do this multiple times, with different conditions and arguments. Obviously I could type this out multiple times, but surely we all agree cut and pasting code is a bad idea. So my question to you is, how can I best achieve this in the smallest amount of code?

My first attempt involved definining a subroutine:
sub EVENT { $kernel->post( shift, event => @_ ) }; #basically ... EVENT $session, "argh" if $condition;
This is nice and short, as it should be, but it lacks the temrinating 'return' and I can not devise a good method to make the sub EVENT do it.

Any bright ideas?