I have several different perl programs that use the same initial variables for configuration purposes. I have all of these variables in a configuration file called config.pl.
config.pl:
Code:
#mon config settings
our $mondir = "/opt/mon";
our $mapdir = "$mondir/test/maps";
then in my program I require the file and use the variables:
prog.pl
Code:
#!/usr/bin/perl -w
#
require "./config.pl";
#open directory and store files in array
opendir( MAPS,"$mapdir"); #mapdir is correct from required file.
my @maps = grep !/^\.\.?$/,readdir MAPS;
closedir(MAPS);
This actually works great. The problem is that I would like to
. when I do, all of my included variables need to be declared which is a pain. Is there a way to do both of these things? I have looked into packages somewhat but that seems like an aweful lot of work just to include a couple variables. Thanks!