Alright, I found a solution that isn't perfect, but suits my needs thus far. Since the Utilities project includes a logger package that is used by practically every other script (and which already has tenuously appropriate functions ;) ), I managed to put a "get_script_dir" function into it that other scripts can use to figure out where they are (it is exported along with multiple other things for convenience):

sub get_script_dir { #Get the calling script's path my $sc_path = (caller)[1]; #Parse the (possibly relative) directory out of the filename $sc_path =~ m/^(.*[\/\\]+)[^\/\\]*$/; $sc_path = $1 || "."; #Append a trailing slash if there isn't one, for consistency $sc_path .= "/" unless m/[\/\\]$/; return $sc_path; }

 

Then, in every script that isn't a Package/Module, I start with the following:

#!/usr/bin/perl use strict; use warnings; use FindBin; use lib "$FindBin::Bin"; use lib "$FindBin::Bin/Utilities"; ...etc...

 

This way, scripts will call packages from their working directories regardless of the cwd (any script executed via 'system', etc - rather than just used - will inherit its own, relative, FindBin value). Any Package/Module/Script that feels the need to execute something in its own path can then call something like system(get_script_dir() . "some_executable"); which should™ always work.

It's not amazing, and probably slightly hacky, but it's the most efficient method to overcome Perl's trouble with script-relative paths that I could produce so far. I'm still open to any better solutions, but at this point I'm not expecting any :)

 

As an adendum, something that I completely failed to mention in the orignal post, is that most of the servers should be expected to be only running core versions of Perl 5.8.8 on RedHat. Not that's reeaally changed anything, but still, I'm noting this now, for reference.


In reply to Re: Executing a program from within a Perl Module in a non-standard path by GoldElite
in thread 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.