<?xml version="1.0" encoding="windows-1252"?>
<node id="62737" title="How do I reference methods?" created="2001-03-07 11:50:32" updated="2005-08-12 22:28:45">
<type id="1857">
categorized question</type>
<author id="11732">
QandAEditors</author>
<data>
<field name="doctext">
With a normal sub I can do this:
&lt;code&gt;
$ref = \&amp;MyFunc;
&lt;/code&gt;

..which will make $ref a reference to the sub MyFunc. But 
how do I do it if MyFunc is a method in the $self object?
I want to make a reference to &lt;c&gt;$self-&gt;MyFunc&lt;/c&gt; so $self is
passed when I call it, but neither
&lt;code&gt;
$ref = \&amp;$self-&gt;MyFunc;
&lt;/code&gt;

nor
&lt;code&gt;
$ref = \$self-&gt;MyFunc;
&lt;/code&gt;

seems to work. Perl says "Undefined subroutine" for the 
first, and "not a CODE reference" for the second. So, 
question is, how do I reference a method so the object is
sent when I call the reference, or is there a workaround for
the problem?
</field>
<field name="parent_node">
1838</field>
</data>
</node>
