GoldElite has asked for the wisdom of the Perl Monks concerning the following question:
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 :)
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Executing a program from within a Perl Module in a non-standard path
by tobyink (Canon) on Mar 19, 2013 at 13:41 UTC | |
by GoldElite (Beadle) on Mar 20, 2013 at 11:53 UTC | |
by tobyink (Canon) on Mar 20, 2013 at 15:30 UTC | |
Re: Executing a program from within a Perl Module in a non-standard path ($PATH/%PATH%)
by Anonymous Monk on Mar 19, 2013 at 11:49 UTC | |
by GoldElite (Beadle) on Mar 20, 2013 at 11:45 UTC | |
Re: Executing a program from within a Perl Module in a non-standard path
by GoldElite (Beadle) on Mar 20, 2013 at 12:14 UTC |