From: David C. <da...@ra...> - 2007-03-26 21:35:34
|
I modified my copy of NMStreq.pm to optionally read a second configuration= file of default values. It makes maintaining many TFMail configuration= files easier. In each primary/_config configuration file that I want to use defaults for= settings I didn't specify, I set "defaults" to a filename (without= extension) of a configuration file containing default values. I added the following 9 lines in sub new, after the primary configuration= file is read, and before CGI parameters are loaded: my $cfg_name2 =3D $self->config('defaults'); if ($cfg_name2) { my $config2 =3D $self->_read_config_file($cfg_name2); while ( my($key, $val) =3D each %$config2 ) { $self->{r}{config}{$key} =3D $val unless exists= $self->{r}{config}{$key}; } } I am not a Perl expert, so I assume there are better code and methods to= fulfill my objective. For example, loading defaults for keys already set= could be avoided by modifying sub _read_config_file. That would also= remove a loop and reduce memory use and code needed. But, I avoided= modifying existing code. I joined this email list yesterday. David |