title: How to dynamically load modules and execute methods in perl
body: <p>I'm following up on this <a href="https://stackoverflow.com/questions/6336270">question</a> about perl web services.  I've managed to get modules loading and executing from a main program.  Each of the modules is something like this:</p>
  
  <pre><code>#!/usr/bin/perl
  package NiMbox::perlet::skeleton;
  
  use strict;
  use warnings;
  
  require Exporter;
  our @ISA = qw(Exporter);
  our @EXPORT_OK = qw(%DEFINITION main secondary);
  
  our %DEFINITION;
  $DEFINITION{'main'} = {
      summary =&gt; 'skeleton main',
      description =&gt; 'long skeleton main description',
      args =&gt; { 'box' =&gt; {}, 'other' =&gt; {} }
  };
  $DEFINITION{'secondary'} = {
      summary =&gt; 'skeleton secondary',
      description =&gt; 'long skeleton secondary description'
  };
  
  sub main {
      print "main...\n";
  }
  
  sub secondary {
      print "secondary...\n"
  }
  
  1; 
  </code></pre>
  
  <p>And invocation of these modules can then be done like this:</p>
  
  <pre><code>use NiMbox::perlet::skeleton;
  
  my %DEFINITION = %NiMbox::perlet::skeleton::DEFINITION;
  foreach my $s (keys %DEFINITION) {
      print "calling sub '$s'\n";
      NiMbox::perlet::skeleton-&gt;$s();
  }
  </code></pre>
  
  <p>How would I get rid of the direct invocation of <code>NiMbox::perlet:skeleton</code> in a way in which I could do something that looks like this (which does not work but illustrates what I need to do):</p>
  
  <pre><code>my $perlet = 'skeleton';
  
  use NiMbox::perlet::$perlet;
  
  my %DEFINITION = %NiMbox::perlet::$perlet::DEFINITION;
  foreach my $s (keys %DEFINITION) {
      print "calling sub '$s'\n";
      NiMbox::perlet::$perlet-&gt;$s();
  }
  </code></pre>
  
  <p>Since I'm very close I would rather see what is missing in this example rather than use another library.  Any ideas?</p>