title: perl dynamic path given to 'use lib'
body: <p>So, my code (Perl scripts and Perl modules) sits in a tree like this:  </p>
  
  <pre><code> trunk/  
     util/  
     process/  
     scripts/  
  </code></pre>
  
  <p>The 'util' directory has, well, utilities, that things in the 'process/' dir need. They get access like this:</p>
  
  <pre><code>use FindBin;
  use lib "$FindBin::Bin/../util";
  use UtilityModule qw(all);
  </code></pre>
  
  <p>That construct doesn't care where you start, as long as you're at the same level in the tree as "util/".<br>
  But I decided that 'scripts/' was getting too crowded, so I created  </p>
  
  <pre><code>   scripts/scripts1  
     scripts/scripts2  
  </code></pre>
  
  <p>Now I see that this doesn't work. If I run a script 'trunk/scripts/scripts1/call_script.pl', and it calls '/trunk/process/process_script.pl', then 'process_script.pl' will fail trying to get the routines from UtilityModule(), because the path that FindBin returns is the path of the top-level calling script. </p>
  
  <p>The first ten ways I thought of to solve this all involved something like:  </p>
  
  <pre><code>use lib $path_that_came_from_elsewhere;
  </code></pre>
  
  <p>but that seems to be something Perl doesn't like to do, except via that FindBin trick.  </p>
  
  <p>I tried some things involving BEGIN{} blocks, but i don't really know what I'm doing there, and will likely just end up refactoring. But if someone has some clever insight into this type of problem, this would be a good chance to earn some points!</p>