title: 'use lib' can't find Perl module
body: <p>I'm on Windows 7, I downloaded a <a href="http://search.cpan.org/~msergeant/XML-XPath-1.13/" rel="nofollow noreferrer">CPAN module</a> called <code>XML::XPath</code>, and I want to use it in a script I wrote.  </p>
  
  <p>I cannot modify <code>@INC</code> on my machine, I cannot modify environmental variables on my machine, I cannot run <code>make</code> on my machine, and I cannot use a package manager on my machine.</p>
  
  <p>So in order to use the module, I went to the CPAN website, downloaded the module's <code>.tar.gz</code> file, and unzipped it into a <code>lib</code> folder in my project. I did that because <a href="https://perlmaven.com/how-to-change-inc-to-find-perl-modules-in-non-standard-locations" rel="nofollow noreferrer">this guide</a> suggested that I can use <code>use lib</code> in the context of my script to reference the downloaded module:</p>
  
  <blockquote>
    <p>Adding a use lib statement to the script will add the directory to @INC for that specific script. Regardless who and in what environment runs it.</p>
  </blockquote>
  
  <p>My script is called <code>test.pl</code>.  I am trying to use the <code>XML::XPath</code> module to parse an XML file called <code>test.xml</code>.  Here is an example of my directory structure:</p>
  
  <pre><code>C:/
    → sandbox/
        test.pl
        test.xml
      → lib/
        → XML-XPath-1.13/
            XPath.pm
          → XPath/
              XMLParser.pm
              (etc.)
  </code></pre>
  
  <p>This is my <code>test.pl</code> script:</p>
  
  <pre><code>#!/usr/bin/perl
  use strict;
  use warnings;
  use lib qw("C:/sandbox/lib/XML-XPath-1.13");
  
  my $xml_file = "C:/sandbox/test.xml";
  my $result;
  
  if (-f $xml_file) {
    $result = XML::XPath-&gt;new(filename =&gt; "$xml_file");
  }
  </code></pre>
  
  <p>When I run this script with <code>perl test.pl</code>, the script fails with the following error:</p>
  
  <blockquote>
    <p>Can't locate object method "new" via package "XML::XPath" (perhaps you forgot to load "XML::XPath"?) at test.pl line 10.</p>
  </blockquote>
  
  <p>Can I resolve this error with <code>use lib</code>?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>When I add <code>use XML::XPath;</code> to my <code>test.pl</code> script, as such:</p>
  
  <pre><code>#!/usr/bin/perl
  use strict;
  use warnings;
  use lib qw("C:/sandbox/lib/XML-XPath-1.13");
  </code></pre>
  
  <p>I get an error like: </p>
  
  <blockquote>
    <p>Can't locate XML/XPath.pm in @INC</p>
  </blockquote>
  
  <p>But as stated above, I cannot physically modify <code>@INC</code> or recompile Perl on my machine.</p>