Config::Reload - Load config files, reload when files changed.
version 0.21
my $config = Config::Reload->new( wait => 60, # check at most every minute (default) ... # passed to Config::ZOMG, e.g. file => $filename ); my $config = $config->load; sleep(60); $config = $config->load; # reloaded
This Perl package loads config files via Config::ZOMG which is based on Config::Any. Configuration is reloaded on file changes (based on file names and last modification time).
This package is highly experimental and not fully covered by unit tests!
Returns a new Config::Reload object. All arguments but wait, error and checked are passed to the constructor of Config::ZOMG.
Config::Reload
wait
error
checked
Get the configuration, possibly (re)loading configuration files. Always returns a hash reference, on error this { } .
{ }
Get or set the number of seconds to wait between checking. Set to 60 (one minute) by default.
Returns a timestamp of last time files had been checked.
Returns a timestamp of last time files had been loaded. Returns undef before first loading and on error.
undef
Returns a list of files that configuration has been loaded from.
Returns a list of files that configuration will be loaded from on next check. Files will be reloaded only if files_hash value of of find differs from the value of found:
files_hash
find
found
use Config::Reload qw(files_hash); files_hash( $config->find ) ne files_hash( $config->found )
Returns an error message if loading failed. As long as an error is set, the load method returns an empty hash reference until the next attempt to reload (typically the time span defind with wait). One can manually unset the error with $c->error(undef) to force reloading.
load
$c->error(undef)
Returns a hexadecimal MD5 value based on names, -sizes and modification times of a list of files. Internally used to compare find and found.
This function can be exported on request.
Jakob Voß
This software is copyright (c) 2013 by Jakob Voß.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Config::Reload, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Config::Reload
CPAN shell
perl -MCPAN -e shell install Config::Reload
For more information on module installation, please visit the detailed CPAN module installation guide.