Subject: | Config::Simple::Extended needs a ->watch() constructor |
perldoc Log::Log4perl
# Check config every 10 secs
Log::Log4perl::init_and_watch('/etc/log4perl.conf',10);
We need a similar feature for a Config::Simple object
UNTESTED
package My::New::Module;
sub new {
my $class = shift;
my $defaults = shift;
my $watch_interval = shift || undef;
my $self = {};
if(defined($defaults->{'config_file'})){
$self->{'cfg'} = Config::Simple::Extended->watch(
$defaults->{'config_file'}, $watch_interval );
} elsif(defined($defaults->{'config_files'})){
my $cfg;
undef($cfg);
foreach my $file (@{$defaults->{'config_files'}}){
$cfg = Config::Simple::Extended->inherit({
base_config => $cfg,
filename => $file }, $watch_interval );
}
$self->{'cfg'} = $cfg;
} else {
die "Constructor invoked with no Confirguration File."
}
my $db = $self->{'cfg'}->get_block('db');
# print STDERR Dumper(\$db);
$self->{'dbh'} = My::New::Module::DB->connect($db);
bless $self, $class;
return $self;
}
Have ->inherit(), use ->watch(),
and ->watch() use Config::Simple->new().