I wrote a small perl application for deployment on multiple servers. It consists of some scripts, some modules, and some data files. It will be used by several users. I would like to save all these files in one directory, and not move the application modules to the site_perl directory.
For example, let's say an application consists of jump.pl swim.pl Common.pm and messages.txt
The application (either jump.pl or swim.pl) will be called from another directory. The application installation location may not be in $ PATH so that the user (or another application) can call it using an absolute path, such as /some/path/swim.pl , or a relative path, such as ../path/swim.pl
I would like the application to be as simple as possible, which means that the path to the application is as few places as possible.
Currently swim.pl and jump.pl begin as follows
#!/usr/bin/perl use strict; use warnings; use lib '/some/path'; use Common;
So, I have /some/path in several places in several scripts and modules.
I considered the following as a possible means to minimize the number of different storage locations /some/path
- Set the environment variable
PERL5LIB=/some/path and execute open my $fh, '<', "$ENV{PERL5LIB}/messages.txt" - Set the shebang line to
#!/usr/bin/perl -I/some/path - but then how to find messages.txt? - Try
use Cwd qw(abs_path); and find a way to use basename abs_path($0) for use lib in BEGIN ?
Any suggestions for maximizing location flexibility, storing everything, minimizing multiple hard-coded installation locations?
source share