Hi all,

Sorry for the long title, I'm having trouble articulating just the issue I'm having

Basically I'm wondering what is the best way, without using absolute paths, to set up my files so that modules AND non-modules (such as YAML files) can be referenced easily in a script. I often reference a module using "use lib()" and those modules often reference yaml files using absolute paths. I've come to realize that if I move those files to other computers I cannot easily set up the paths so everything is included properly (see below for more info). Even if I start keeping the modules in the same DIR as the script (or one level below in a modules DIR for example) I cannot use relative paths in the case that the script is not run from the directory that it resides (if Cron were running it for example).

What is the best practice to ensure portability for modules and other files a script might need to reference?

Here's why I'm asking:

Up until this point I have been working with Perl with only two different Linux machines where. I set up the directory structures identically so when I wanted to move a script from one machine to another I just needed to copy it and any "use lib" includes I wanted would work fine.

I now have a few more machines, VMs, etc and thought it would be a good idea to set up source control for additional users, etc. So I created a few GIT repositories and realized, as I was trying to add files into the repo so they could be replicated to other machines, I could no longer use a hierarchy where I put all PM files in a single dir and all YAML files in another and still break the repo into smaller projects rather than a big monolithic repo (there would be issues even with that since the placement of the cloned repo is not assured.


In reply to Help with Best Practices for Module Paths when scripting across multiple machines by mwb613

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.