in reply to Cutting repetition in POE coding
It does sound rather as though you're looking for a way to make a sub force its caller to return. You may be interested, amused, and/or horrified to know that Want provides an (undocumented) way to do just this. If you call Want::double_return(), then the next ordinary return will return from the calling sub.
For example, the code:
prints the following:use Want; sub foo { print "Entering foo\n"; bar(); print "Leaving foo\n"; return "foo did this"; } sub bar { print "Entering bar\n"; print "Leaving bar\n"; Want::double_return(); return "bar did this"; } print "About to call foo()\n"; my $r = foo(); print "foo() returned '$r'\n";
About to call foo() Entering foo Entering bar Leaving bar foo() returned 'bar did this'
Update: so in your case, you could write
sub EVENT { $kernel->post( shift, event => @_ ); Want::double_return(); return; }
|
---|
In Section
Seekers of Perl Wisdom