Tintin has asked for the wisdom of the Perl Monks concerning the following question:
$base='/home/foo';<BR> $logdir="$base/logs";<BR> $admindir="$base/logs";<BR>
etc. Obviously there are a lot more entries in the real config file.
At present, I'm in two minds as to how to handle editing of the file via a form.
1.) I can just do a 'require config'; and then use the values of the various variables set in the file, eg: $admindir. The only problem with this approach is if someone changes $base, then they will need to manually change all the other variablesas their values will be expanded.
2.) Change the format of the config file and read it in by splitting the variable name and value, eg:
while (<CONFIG>) { next if (/^#/); ($var,$value) = split(/=/); $value =~ s/[\$,",',;]//g; $configvar{$var}=$value; }
Obviously approach one is much simplier, but flawed (for my purposes) and method two seems very messy.
I suspect I need to look at options 3, 4 and beyond. Opinions welcomed.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Editing configuration file with a CGI Perl script
by jepri (Parson) on Jun 04, 2001 at 17:19 UTC | |
|
Re: Editing configuration file with a CGI Perl script
by wardk (Deacon) on Jun 04, 2001 at 18:37 UTC |