From: Blake M. <bl...@us...> - 2002-04-27 02:33:54
|
Update of /cvsroot/macs/macs/lib/MACS In directory usw-pr-cvs1:/tmp/cvs-serv26717 Modified Files: Config.pm Log Message: now uses environment variable MACS_HOME to find the config file Index: Config.pm =================================================================== RCS file: /cvsroot/macs/macs/lib/MACS/Config.pm,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Config.pm 25 Apr 2002 09:28:30 -0000 1.1 --- Config.pm 27 Apr 2002 02:33:48 -0000 1.2 *************** *** 1,7 **** package MACS::Config; use strict; use Carp; - # where is the config file, is there a better way to do this? - use constant MACS_CONFIG_FILE => '../macs.cfg'; # MACS keeps it's cofnig info in an IniFile use Config::IniFiles; --- 1,6 ---- package MACS::Config; use strict; + use warnings::register; use Carp; # MACS keeps it's cofnig info in an IniFile use Config::IniFiles; *************** *** 19,24 **** @EXPORT_OK = qw($cfg); # should the rest of this be in a BEGIN block? $cfg = tie(%cfg, 'Config::IniFiles', ! -file => MACS_CONFIG_FILE, # what does this do? -default => 'default'); --- 18,31 ---- @EXPORT_OK = qw($cfg); # should the rest of this be in a BEGIN block? + my($config_file); + if(not(-d $ENV{MACS_HOME})) { + # Carp::long_mess appends a stack trace to the given argument + warnings::warnif(Carp::long_mess("\$MACS_HOME improperly defined, using \"..\" instead, this may be wrong")); + $config_file = "../macs.cfg"; + } else { + $config_file = "$ENV{MACS_HOME}/macs.cfg"; + } $cfg = tie(%cfg, 'Config::IniFiles', ! -file => $config_file, # what does this do? -default => 'default'); |