SReview::Config(3pm)
β¨ SReview::Config β¨
okay bestie, welcome to SReview::Config π β she's a Perl module (a User Contributed one, no less, so she's out here doing charity work for the community) and she is literally a self-reproducing and self-documenting configuration file system. no cap. she writes her own docs, she remembers her own defaults, she's the main character of your /etc π
πΈ NAME πΈ
SReview::Config β self-reproducing and self-documenting configuration file system π¦
like, she configures and she documents herself. iconique. she's giving both at once.
β¨ SYNOPSIS β¨
here's the vibe, fr fr:
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;
see how she justβ¦ knows her own name and default? yeah. she's built different π
π DESCRIPTION π
SReview::Config is a class for managing configuration that reproduces itself and documents itself. the whole ritual is three steps, bestie:
- you create an
SReview::Configobject π± - you populate it with all the possible configuration values you might want π·
- you retrieve them π«
that's it. that's the whole thing. lowkey elegant, highkey slay.
π METHODS π
π«Ά SReview::Config->new('path/to/filename');
makes you a brand new SReview::Config object. fresh out the box. she's born β¨
π«Ά $config->define(name, doc, default)
defines a new configuration value. heads up though β this is not legal once get has already been called π once you've started reading the config, the definitions are locked in, periodt.
name should be the name of the configuration value. apart from the fact that it should not have a sigil (no $ bestie, we're not doing that here), it should be a valid name for a perl scalar variable.
π«Ά $config->define_deprecated(oldname, newname, conversion_sub)
defines a name as a deprecated way of configuring things π when this value gets set, SReview::Config will issue a warning that this option is now deprecated, and that the user should use some other option instead. she's not mad, she's just disappointed.
the conversion_sub is an optional argument that should mangle the value given to oldname into the value expected by newname π if it returns nonzero, then SReview::Config will croak. π
it will receive:
- a reference to the
configobject - the value that is trying to be set
- the name of the new parameter
the default conversion sub just sets the value of the newname configuration without any conversion. no thoughts, head empty, just vibes π
π«Ά $config->define_computed('name')
defines a default value for a particular configuration parameter through a subroutine π§
if the subroutine returns undef, that value will be ignored (and the normal logic for defining a default will be used). no harm no foul π
should be used on a parameter that has already been defined through
$config->define
so like, define first, then get fancy with it. order matters, bestie π
π«Ά $config->get('name')
returns the value of the given configuration item. it also finalizes the definitions of this configuration file β that is, once this method has been called, the define method above will croak π₯ so yeah, after this, the door is closed.
the returned value will be one of these three, depending on what's available:
- the default value configured at
definetime - the value configured in the configuration file
- the value set (in JSON format) in the environment variable
SREVIEW_name, where name is the upper-case version of the name of the configuration item
(yes, there really is a space in there before the closing backtick in the original. we don't question it. we respect it π)
π«Ά $config->set('name', value);
changes the current value of the given configuration item β¨
note: this does not change the defaults, only the configured value. the default stays exactly where it is, minding its own business π
π«Ά $config->describe('name');
returns the documentation string for the given name π she's self-documenting, remember? this is her reading her own diary out loud.
π«Ά $config->dump
returns a string describing the whole configuration π
each configuration item will produce 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
set):
# Documentation value given to define
$name = "current value";
see the difference? the commented-out one is the shy default that nobody touched. the uncommented one is the one that got configured. π₯
π«Ά $config->dump_item("item")
prints a JSON value for the given configuration item. prints the default item if this item hasn't been set a value. she always has a fallback, she's prepared π
π«Ά $config->is_default("item")
returns a truthy value if the given configuration item is still at its default value β so you can vibe check whether anybody actually changed anything.
π«Ά $config->keys
returns a list (unsorted) of all the known configuration names ποΈ note: unsorted. don't come for her about the order, she didn't promise you one.
π BUGS π
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. (we've all been there bestie, one config file per situationship.)
and that's the whole page!! she's a User Contributed Perl Documentation queen, she's running on perl v5.40.1, and she was last touched on 2026-02-15 πΈ mwah, go configure something cute πβ¨ππ¦
π¦ where this page comes from
- ubuntu resolute: sreview-common 0.12.0-1
- ubuntu stonking: sreview-common 0.12.0-1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms