<?xml version="1.0" encoding="windows-1252"?>
<node id="511961" title="Re: Cutting repetition in POE coding" created="2005-11-26 18:26:43" updated="2005-11-26 13:26:43">
<type id="11">
note</type>
<author id="117983">
robin</author>
<data>
<field name="doctext">
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 &lt;tt&gt;Want&lt;/tt&gt; provides an (undocumented) way to do just this. If you call &lt;code&gt;Want::double_return()&lt;/code&gt;, then the next ordinary &lt;tt&gt;return&lt;/tt&gt; will return &lt;i&gt;from the calling sub&lt;/i&gt;.
&lt;p&gt;
For example, the code:
&lt;code&gt;
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";
&lt;/code&gt;
prints the following:
&lt;code&gt;
About to call foo()
Entering foo
Entering bar
Leaving bar
foo() returned 'bar did this'
&lt;/code&gt;
&lt;p&gt;
&lt;b&gt;Update&lt;/b&gt;: so in your case, you could write
&lt;code&gt;
sub EVENT {
    $kernel-&gt;post( shift, event =&gt; @_ );
    Want::double_return();
    return;
}
&lt;/code&gt;
&lt;/p&gt;</field>
<field name="root_node">
511869</field>
<field name="parent_node">
511869</field>
</data>
</node>
