>>>>> "M" == M Lewis <[EMAIL PROTECTED]> writes:
M> do '/absolute/path/to/mcr.conf';
M> Which defeats my purpose of getting the configuration items out of the
M> scripts themselves. I don't want the users to have to edit the three
M> scripts, only the mcr.conf file.
If your configs are relative to the file itself, consider that
__FILE__ is the name of the current file, *when* compiled. So,
if you have to pull in an additional file that's in the same directory
as your module or script, just add:
BEGIN {
use File::Spec;
my @place = File::Spec->splitpath(__FILE__);
$place[-1] = "config.pl";
require File::Spec->catpath(@place);
}
This guarantees to bring in a file named config.pl in the same directory
as your script (if used from the main program) or the .pm file if used
from the module.
A simpler version is like this:
BEGIN {
require __FILE__ . "-config.pl";
}
which makes the config file "fred-config.pl" for a program named fred,
or "fred.pm-config.pl" for the fred.pm module. If your OS can handle
funky names like that, you're golden.
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[email protected]> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>