<?xml version="1.0" encoding="windows-1252"?>
<node id="892689" title="Re: Passing an anonymous block to a method." created="2011-03-11 11:25:12" updated="2011-03-11 11:25:12">
<type id="11">
note</type>
<author id="25825">
TGI</author>
<data>
<field name="doctext">
&lt;p&gt;Since prototypes are compile time effects and method resolution happens at run time there is no (easy) way to make them happy together.  You could do something with a sub based wrapper:

&lt;c&gt;
sub do_this (&amp;$$;@)  {
    my $code = shift;
    my $method = shift;
    my $obj = shift;
    $obj-&gt;$method( $code, @_ );
}


do_this {$_ += 1}  do_it =&gt; $o,  'fred';
&lt;/c&gt;

&lt;p&gt;Yep, it's all backwards order-wise.  By using multiple prototyped subs you might be able to make a saner syntax.  Something like  this: &lt;c&gt;run_code { 'foo' } on_object $o  with_method 'bar' and_args 'fred'&lt;/c&gt;, but less stupid.

&lt;!-- Node text goes above. Div tags should contain sig only --&gt;
&lt;div class="pmsig"&gt;&lt;div class="pmsig-25825"&gt;
&lt;P&gt;&lt;BR&gt;TGI says &lt;B&gt;moo&lt;/B&gt;&lt;/P&gt;
&lt;/div&gt;&lt;/div&gt;</field>
<field name="root_node">
892443</field>
<field name="parent_node">
892443</field>
</data>
</node>
