title: Calling a Module Function By Reference
body: <p>I am looking at building a dispatch table for calling a number of Perl modules that I wrote.</p>
  
  <p>As an example, if I have a package called <code>Hello.pm</code> with a simple function <code>hello()</code> in it, I would like to get a code reference to this function.</p>
  
  <p>The following does not work:</p>
  
  <pre><code>my $code_ref=\&amp;Hello-&gt;hello();
  $code_ref-&gt;();
  </code></pre>
  
  <p>But if the function hello is exported from the package, then the following works:</p>
  
  <pre><code>my code_ref=\&amp;hello;
  code_ref-&gt;();
  </code></pre>
  
  <p>Does anyone know the correct syntax for the first case? Or is this simply not possible?</p>
  
  <p>In the end, I would like to populate a hash table with all my code references.</p>
  
  ##### Thanks for All Answers
  
  <p>The correct invocation as pointed out by several answers is:</p>
  
  <pre><code>my $code_ref=\&amp;Hello::hello;
  $code_ref-&gt;();
  </code></pre>
  
  <p>I have some 10 modules in 10 different files that I would like to load in a dispatch table.
  This makes it easier for me to have the configuration loaded as data, and separate from code.
  This allows me to load additional modules in a testbench without modifying my code-simply modify the configuration file.  Mark Dominus, author of Higher Order Perl, has some nice examples on this.</p>