I'm currently writing a collection of scripts for my company - currently a few projects with inter-dependencies. Since everything is in development - and I can't expect to have particularly priviliged access to the resulting server - dependant projects are stored in subdirectories of the owning projects rather than in the proper Perl Module paths (Nothing Too Special here, I hope).

For example, three separate projects "Checkout", "Utilities" and "Transfer" can have the following heirarchy:

Checkout
Checkout/Utilities
Checkout/Transfer
Checkout/Transfer/Utilities (Obviously not necessary in this particular setup, but shown for demonstration)

 

So, I have two queries I humbly submit to you, enlightened Monks of the Monastery.

Firstly: use lib 'Utilities' and use lib 'Transfer' (in Checkout scripts) both work fine if I'm running the script from the directories they are stored in, but not elsewhere because for some raisin - assumedly to do with @INC -, Perl doesn't consider a script's home to be the obvious search directory. I'm using FindBin in the root project and while it works, it feels a bit cludgy. Is this more-or-less correct or am I missing some sage wisdom here?

Secondly: More importantly, though, is that some of these packages need to call some non-Perl programs. Even though I keep them in their relative project directories, FindBin is powerless to assist in this general sense. For example, the following will fail because './rdiff' is not in the current working directory:

---./checkout.pl use lib 'Transfer'; use DiffScript; DiffScript::generateDiff(); ---Transfer/DiffScript.pm package DiffScript; sub generateDiff { eval('./rdiff args1 args2 etcargs'); }

What would I do in this instance? The application (i.e. 'rdiff') is tied to the Transfer project, and I don't want to introduce extra coupling by forcing every higher-up project to supply a path to every module just for cases like this. The idea is to keep the projects as decoupled as possible, with the top-most project in an arbitrary root directory.

 

I've searched for a while and have turned up perilously little in this regard! I really hope any of you can shed some light on this :)


In reply to Executing a program from within a Perl Module in a non-standard path by GoldElite

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.