title: What is the proper way in Perl to dynamically and repeatedly load code?
body: <p>I have a perl script that needs to execute some known-at-runtime number of sub-scripts sequentially, but it would be helpful/convenient if the sub-scripts shared the state info of the main program (the sub-script does not need to change the state info, though). The main script would be called with the name of a directory of ZIP files, and each ZIP file would have in it a perl module/library/script, presumably with the same name, but that doesn't need to be the case.</p>
  
  <p>Some things I've thought of trying:</p>
  
  <ol>
  <li>have each sub-script provide a RunMe.pm module which would get loaded, used, then unloaded (via manipulating <code>%INC</code> -- ugh)</li>
  <li>fork for each sub-script, <code>require</code> or <code>use</code> RunMe.pm, do whatever, then exit</li>
  <li>write a perl library instead and <code>do</code> or <code>eval</code> the library (though I think using <code>do</code> would still require manipulating <code>%INC</code>)</li>
  </ol>
  
  <p>In Java I would have a class implement an interface and have a factory to create all of them, though I wouldn't know the names of the implementing classes at compile time, so I'd resort to Class.forName().</p>
  
  <p>All of this is kind of on the ugly side and is leading me to reconsider the design idea entirely, which may be the correct answer here.</p>