SReview::Config - Self-reproducing and self-documentating configuration file system
use SReview::Config; my $config = SReview::Config->new('/etc/sreview/config.pm'); $config->define('name', 'The name of this element', 'default'); ... print "You configured " . $config->get('name') . " as the name\n"; print "Full configuration: \n" . $config->dump;
SReview::Config is a class to easily manage self-reproducing and self-documenting configuration. You create an SReview::Config object, populate it with possible configuration values, and then retrieve them.
Create a new SReview::Config object.
Define a new configuration value. Not legal after
get has already been called.
Name should be the name of the configuration value. Apart from the fact that it should not have a sigil, it should be a valid name for a perl scalar variable.
Return the value of the given configuration item. Also finalizes the definitions of this configuration file; that is, once this method has been called, the
define method above will croak.
The returned value will either be the default value configured at
define time, or the value configured in the configuration file.
Change the current value of the given configuration item.
Note, this does not change the defaults, only the configured value.
Return the documentation string for the given name
Return a string describing the whole configuration.
Each configuration item will produced in one of the following two formats:
For an item that only has a default set:
# Documentation value given to define #$name = "default value";
For an item that has a different value configured (either through the configuration file, or through
# Documentation value given to define $name = "current value";
It is currently not possible to load more than one configuration file in the same process space. This will be fixed at some point in the future.