I think this demonstrates the problem with the truth-but-not-the-whole-truth. Absolute paths do need to be avoided in source code, to enable the users or their adminstrators to follow their own installation policies rather than have every application that comes along make its own sweet rules for where it is installed and what working directories it uses.

In the well-ordered world of Unix and Linux, shared libraries, applications and even data to some extent, have conventional places to live, many absolute paths are indeed absolutely reliable - but I do say only 'many'.

In particular, a system adminstrator desperately needs the freedom to categorise applications according to a number of considerations, including whether the application is meant to be invoked ad hoc, at user login, or during what level of system startup, which will influence his personal or required choices of installation and working paths.

The standard solution to address all such considerations is to place absolute paths in configuration files which are then either loaded into environment variables, accessible via %ENV, or a perl subroutine may load them directly, early in the execution of an application.

But really conscientious applications will also define all subdirectories in configuration files so that the code is not only 100% free of hard-coded absolute paths but of hard-coded relative paths as well! Even those relative paths will then be computed into absolute paths at run-time and may also be configured by the user without touching the code.

One world, one people


In reply to Re: Best practices - absolute paths? by anonymized user 468275
in thread Best practices - absolute paths? by Eyck

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.