<?xml version="1.0" encoding="windows-1252"?>
<node id="1009707" title="Re: effects of ampersand and non ampersand when referencing a sub name" created="2012-12-20 03:56:55" updated="2012-12-20 03:56:55">
<type id="11">
note</type>
<author id="757127">
tobyink</author>
<data>
<field name="doctext">
&lt;p&gt;Using a coderef &lt;em&gt;at all&lt;/em&gt; bypasses prototypes. (As does calling a sub as a method.)&lt;/p&gt;
&lt;p&gt;If you need to check the number of arguments passed to a sub, &lt;strong&gt;do it in the sub!&lt;/strong&gt; Prototypes are just to help the Perl parser parse argument lists more sanely.&lt;/p&gt;
&lt;c&gt;
sub execute {
   @_==3 or croak "execute() needs three arguments!!";
   ...;
}
&lt;/c&gt;

&lt;!-- Node text goes above. Div tags should contain sig only --&gt;
&lt;div class="pmsig"&gt;&lt;div class="pmsig-757127"&gt;
&lt;small&gt;&lt;small&gt;
&lt;tt&gt;perl -E'sub Monkey::do{say$_,for@_,do{($monkey=&amp;#x5B;caller(0)]-&gt;&amp;#x5B;3])=~s{::}{ }and$monkey}}"Monkey say"-&gt;Monkey::do'
&lt;/tt&gt;&lt;/small&gt;&lt;/small&gt;
&lt;/div&gt;&lt;/div&gt;</field>
<field name="root_node">
1009702</field>
<field name="parent_node">
1009702</field>
</data>
</node>
