[ale] Perl Question

michael d. ivey ivey at gweezlebur.com
Tue Mar 2 10:05:46 EST 2004


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   :



More information about the Ale mailing list