I have a script that I'm slowly converting to a package, and it needs some system modules to be either installed, or delivered with the package.

When I call the script, which uses Foo::Config.pm (my local Config.pm, in ./Foo), Config.pm calls other modules like Color::Rgb, and then dies saying that Color/Rgb.pm could not be found in @INC.

How do I add ./Foo to @INC, so it can find ./Foo/Color/Rgb.pm (which I manually put there, from the Color::Rgb package itself).

Also, when testing this script, how can I be sure that the modules I'm calling from my script are coming from . or ./Foo and subdirectories, and not from the system @INC itself? I need to make sure that the modules I deliver with my code are the ones read, and not system-installed modules of the same name.

I'm aware that PAR can do this, but PAR is not an option here. I'm simply trying to figure out how to get the modules to be called locally. If I cd to ./Foo, and run ./Config.pm directly, it finds the module under ./Color, as it should, but not from the directory above ./Foo that my script resides in. If I have 20 modules that I need to deliver with this script, should I just create all of the ./This/That/TheOther/Module.pm directories directly (assuming a This::That::TheOther::Module module)?


In reply to Differentiating between local and system modules by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.