title: How can I call a Perl package I define in the same file?
body: <p>I need to define multiple modules in the same file. I would like to do something like the following:</p>
  <pre><code>package FooObj {
      sub new { ... }
      sub add_data { ... }
  }
  
  package BarObj {
      use FooObj;
      sub new { 
          ... 
          # BarObj &quot;has a&quot; FooObj
          my $self = ( myFoo =&gt; FooObj-&gt;new() );
          ...
      }
      sub some_method { ... }
  }
  
  my $bar = BarObj-&gt;new();
  </code></pre>
  <p>However, this results in the message:</p>
  <blockquote>
  <p>Can't locate FooObj.pm in @INC ...<br />
  BEGIN failed...</p>
  </blockquote>
  <p>How do I get this to work?</p>