title: Perl - Package/Module Issues
body: <p>From everything I've read on using Perl modules, the basic usage is:</p>
  
  <ul>
  <li>Module file with <code>.pm</code> extension, which includes the statement <code>package &lt;name&gt;</code>, where <code>&lt;name&gt;</code> is the filename of the module without the extension.</li>
  <li>Code file that uses module contains the statement <code>use &lt;name&gt;;</code>.</li>
  </ul>
  
  <p>The application I'm coding has one main code script which uses about 5 modules. I had forgotten to include the <code>package &lt;name&gt;</code> statement in the modules, but my code still ran just fine with the <code>use &lt;name&gt;</code> statement. I started receiving <code>Undefined subroutine</code> errors with one of the modules, so I added the package statement to each of the modules. Now the rest of those modules <strong>stopped</strong> working. What gives?</p>
  
  <p><em>Example:</em></p>
  
  <p>mainapp.pl</p>
  
  <pre><code>#!/usr/bin/perl
  use UtyDate;
  my $rowDate = CurrentDate("YYYYMMDD");
  </code></pre>
  
  <p>UtyDate.pm</p>
  
  <pre><code>#!/usr/bin/perl
  package UtyDate;
  sub CurrentDate
  {
      #logic
  }
  return 1;
  </code></pre>
  
  <p>When I run the above code, I get the error <code>Undefined subroutine &amp;main::CurrentDate called at...</code>. However, if I remove the <code>package UtyDate;</code> line from UtyDate.pm, I get no error. This situation exists for several but not all of my modules.</p>
  
  <p>There's obviously a lot more code I'm not showing, but I'm confused how any of the code I'm not showing could affect the package/use constructs I've shown here.</p>