Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Cutting repetition in POE coding

by robin (Chaplain)
on Nov 26, 2005 at 23:26 UTC ( #511961=note: print w/ replies, xml ) Need Help??


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:

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";
prints the following:
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; }


Comment on Re: Cutting repetition in POE coding
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://511961]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (10)
As of 2015-07-07 01:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (86 votes), past polls