[ale] Perl Question

Chris Fowler cfowler at outpostsentinel.com
Tue Mar 2 14:42:26 EST 2004


Is there a way to add an include path to the perl program for *.pm
modules?

On Tue, 2004-03-02 at 10:04, michael d. ivey wrote:
> 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.



More information about the Ale mailing list