ph713 has asked for the wisdom of the Perl Monks concerning the following question:
The details (excuse the rambling, I'm still figuring this out as I type it):
I'm getting to the latter stages of writing a large project in perl (well, not too large, but on the order of ~10k lines of original code). So here I am with a baseline requisite of perl 5.6.1 existing somewhere on the target machine (in a finite list of possible locations) as my only enforceable requisite. The machines number in the thousands, and there are several different *nix operating systems and cpu manufacturers involved.
The software package I'm deploying already requires a number of Pure Perl modules from CPAN even on 5.8.x, so I include them with the software itself. I don't use any XS modules that aren't in 5.6.x core, because I can't deploy them easily across the various architectures (just because perl happens to be installed doesn't mean that I can build XS modules - perl may have been built far away in space and time where some functional C compiler once existed).
And now that I'm reading Perl Best Practices (!! where was this book a year ago when I started this project ?? :) ), I have a laundry list of new modules I want to use as well, in order to promote more maintainable code.
On to the specific questions:
1) Given that there may be multiple "perl" executables installed somewhere within a finite list of potential "bin" directories, which may or may not be in $PATH in some order, how do I make sure my deployed package executes using only the best available perl? I have a hackish solution (basically, something that even executes under perl5.0 and can search for other perls, examine "perl -v", and re-execute with the best version found), but seeing as the re-execution has to happen fairly early on, and that the initial "perl" which executes the script could be ancient, I pretty much have to stab this code manually into the BEGIN block of scripts, and the application has several seperate scripts and daemons which can be run from the commandline independantly.
2) It's easy enough for me to include a copy of a bunch of CPAN pure perl modules in my private application modules directory to fill in the "gaps" for whatever isn't part of the core set or doesn't happen to be installed via the OS on whatever machine. But how can I cleanly go about making my scripts/modules use the "best available version" between what I supplied and what's available locally? If I ship SuperModule.pm v1.21, and the machine has v1.23, or vice versa, how can I always end up with the latest and greatest?
3) What's the proper way to get your @INC set up for a custom directory for a given application? For example, currently my software package installs under "/opt/bamf" (names changed to protect the innocent), with user-executable scripts in /opt/bamf/bin, executable daemons in /opt/bamf/sbin (some of which are started from an init script, let's not even go there with all the different *nix standards for init scripts), and a tree of perl modules (some from CPAN per above, some custom to this application) under /opt/bamf/lib (like /opt/bamf/lib/Widget/Maker.pm). Of course "/opt/bamf" shouldn't be a hardcoded location, so for now I've made it the "default", and let be overridden by an environment variable, but it's ugly. Every script contains this line very near the top:
It's ugly, and I feel bad even writing it. Anyone have a better approach to all this mess?BEGIN{$ENV{BAMFPATH}||='/opt/bamf';push(@INC,$ENV{BAMFPATH}.'/lib');}
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Deployment Qs
by maverick (Curate) on Oct 06, 2005 at 22:18 UTC | |
by ph713 (Pilgrim) on Oct 07, 2005 at 05:10 UTC | |
by demerphq (Chancellor) on Oct 07, 2005 at 12:00 UTC | |
by ph713 (Pilgrim) on Oct 07, 2005 at 01:04 UTC | |
|
Re: Deployment Qs
by BUU (Prior) on Oct 06, 2005 at 21:23 UTC | |
by ph713 (Pilgrim) on Oct 07, 2005 at 00:31 UTC | |
|
Re: Deployment Qs
by Moron (Curate) on Oct 07, 2005 at 14:01 UTC |