[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ale] Perl Question
- Subject: [ale] Perl Question
- From: ivey at gweezlebur.com (michael d. ivey)
- Date: Tue Mar 2 10:05:46 2004
- In-reply-to: <1078238763.24210.20.camel@devel>
- References: <[email protected]> <[email protected]> <1078237547.23190.11.camel@devel> <[email protected]> <1078238763.24210.20.camel@devel>
On Tue, Mar 02, 2004 at 09:46:03AM -0500, Chris Fowler wrote:
> Correct. I have many variables that are needed for the same scripts.
> If one variable like email address is changed in the config file then I
> want all scripts to use that new value.
You want require:
-------
data.pl:
$foo = "bar";
$baz = "quux";
-------
program.pl:
require "/path/to/data.pl";
do_something_with($foo,$baz);
-------
require demands that a library file be included if it hasn't already
been included. The file is included via the do-FILE mechanism, which is
essentially just a variety of "eval".
See 'perldoc -f require' for details.
If you were doing OO perl, you'd just make a module that exported your
constants, say MyApp::Constants, and then
use MyApp::Constants;
and they'd be exported into your namespace.
--
michael d. ivey [McQ] : "For technical reasons, there will be
<ivey at gweezlebur.com> : no Tuesday next week."
http://gweezlebur.com/~ivey/ : -- unknown
encrypted email preferred :