title: Why am I unable to load a Perl library when using the `do` function?
body: <p>I'm new to Perl, and I'm updating an old Perl website. Every <code>.pl</code> file seems to have this line at the top:</p>
  <pre><code>do &quot;func.inc&quot;;
  </code></pre>
  <p>So I figured I could use this file to tag on a subroutine for global use.</p>
  <h3>func.inc</h3>
  <pre><code>#!/usr/bin/perl
  sub foobar
  {
      return &quot;Hello world&quot;;
  }
  </code></pre>
  <h3>index.pl</h3>
  <pre><code>#!/usr/bin/perl
  do &quot;func.inc&quot;;
  print &quot;Content-type: text/html\n\n&quot;;
  print foobar();
  </code></pre>
  <p>However, I get this error:</p>
  <pre><code>Undefined subroutine &amp;main::foobar called at /path/to/index.pl line 4.
  </code></pre>
  <p>Both files are in the same directory, and there's tones of subs in <code>func.inc</code> already which are used throughout the website. However, the script works in the Linux production environment, but does not work for my Windows 7 dev environment (I'm using ActivePerl).</p>
  <h2>Update:</h2>
  <p>It looks like the file is not being included; the sub works if the file is included using an absolute path...</p>
  <pre><code>do &quot;C:/path/to/func.inc&quot;;
  </code></pre>
  <p>... so it looks like relative paths don't work for my local dev environment, but they work in the production environment through. But this is no good for me, because the absolute path on my dev machine will not work for the live server.</p>
  <p>How do I get <code>do</code> to work using a relative path on my Windows 7 dev machine?</p>
  <h2>Update 2:</h2>
  <p>I was using the Perl <code>-T</code> switch. Unfortunately this removes &quot;.&quot; from @INC, and so stops us from using relative paths for <code>do</code>. I removed this switch and the old code is working now. I'm aware that this is not good practice, but unfortunately I'm working with old code, so it seems that I have no choice.</p>