title: Setting Up Perl Module Structure
body: <p>I'm having trouble figuring out how to structure Perl modules in an object oriented way so I can have one parent module with a number of submodules and only the specific submodules that are needed would be loaded by a calling script. For example I want to be able to make method calls like so:</p>
  
  <pre><code>use Example::API;    
  my $api = Example::API-&gt;new();
  
  my $user = {};
  $user-&gt;{'id'} = '12345';
  
  $api-&gt;Authenticate();
  $user-&gt;{'info'} = $api-&gt;Users-&gt;Get($user-&gt;{'id'});
  $user-&gt;{'friends'} = $api-&gt;Friends-&gt;Get($user-&gt;{'id'});
  </code></pre>
  
  <p>In terms of file structure I'd like to have the modules setup as follows or in whatever structure is required to make everything work correctly:</p>
  
  <pre><code>api.pm
  users.pm
  friends.pm
  ...
  </code></pre>
  
  <p>The reason I want to do this in the first place is so that if someone just wants to authenticate against the API they don't have to load all the other modules. Similarly, if someone just wants to get a user's information, they wouldn't have to load the friends.pm module, just the <code>users.pm</code>. I'd appreciate it if you could provide the necessary example Perl code for setting up each module as well as explain how the file structure should be setup. If I'm going about this all wrong to accomplish what I'm try to accomplish I'd appreciate an explanation of the best way to do this and some example code on how it should be setup. </p>