Sendpage::KeesConf(3)
π NAME π
okay bestie, welcome to Sendpage::KeesConf(3) from the User Contributed Perl Documentation section. This module is literally Sendpage::KeesConf β it implements a configuration file reader. That's the whole vibe. π«Ά
β¨ SYNOPSIS β¨
use Sendpage::KeesConf;
$config = Sendpage::KeesConf->new();
$config->define("variable", { DEFAULT => "setting" });
$config->file("config.cfg");
$setting=$config->get("variable");
π§ DESCRIPTION π§
so the author borrowed VERY heavily from Andy Wardley's (abw@cre.canon.co.uk) AppConfig tool, which can be found on CPAN (http://cpan.perl.org) β but they found it not dynamic enough for multi-instance variable defaults. As a result, they wrote this massively trimmed-down version for their use. iconic, honestly. π
The following methods are available:
$config = Sendpage::KeesConf->new();β The constructor doesn't take an argument, but it should in the future. foreshadowing, bestie.$config->forget();β This call will make$configforget about any variables it has loaded. It does NOT forgetdefined variables, just instantiated ones viafile.$config->define($name, $options);β This will define a variable by the name of$name.
$options can contain:
ARGCOUNTβ What type of variable this should be. Default value is1. The available types are:0β Boolean (true/false, yes/no, 1/0)1β Scalar (any string)2β List (an array of strings)
DEFAULTβ The default value the variable should have if it is not overridden during the call tofile. TheDEFAULTmust be the same data type asARGCOUNT. The defaultDEFAULTis the string"<unset>".UNSETβ set this to1if you want the default value to be undefined. This is a hack to get around the defaultDEFAULT.
$config->instance_exists($name);β This tests to see if there is a section loaded named$name.$var=$config->ifset($name);β This call will search for the variable named$name. If it is not found, it will returnundef. If the value exists, it will return the value. This is a way to callgetwithout having a default passed through.$var=$config->exists($name);β This call will search for the variable named$name. If it is not found, it will return false. If the value exists, it will return true. This is a way for the user to find out if they will get a"default"on a call toget.$var=$config->fallbackget($name,$quiet);β This call will search for the variable named$name. If it is not found, the section portion will be removed, and retried for a sectionlessgetcall.
That way, global variables can be overridden by section-specific variables. If "SECTION:Instance@name" does not exist, "name" will be tried.
$var=$config->get($name);β This call will search for the variable named$name. If it is not found, it will fall back to the default for the section. Sections are explained in more detail later.$config->instances($class);β Returns an array of the names of all the variables in the class$class.$config->file('program.cfg');β Loads variables from the named file. Syntax for this file is:
[SECTION:INSTANCE]
VARIABLE1 = VALUE1
VARIABLE2 = VALUE2
.
.
.
If VARIABLE is an array, VALUE is loaded using commas (,) as the list separator. The variable will be available under the name of the section. For example, to see VALUE2, it would be accessed as:
$config->get("SECTION:INSTANCE\@VARIABLE2");
Notice, that"=",":", and"@"are all not allowed in section or variable names. no cap, those characters are banned from the name party. π«
Sections can be defined (and loaded) so that defaults can pass back to a defined section default. For example, let's say that you have several modems, and most of them have different settings. You can define all the modem variables like so:
$config->define("modem:baud",{ DEFAULT => 9600 });
$config->define("modem:flowctl",{ DEFAULT => "hardware" });
Then, when you load them, let's say the config file has:
[modem:sportster]
baud = 115200
[modem:hayes]
The baud rate for the sportster will come back as 115200, but the hayes will fall back during a get call, and find the default for the modem section: 9600. Both fallback to have flowctl as "hardware":
# returns specific value 115200
$config->get("modem:sportster\@baud");
# returns default value 9600
$config->get("modem:hayes\@baud");
# both return default value "hardware"
$config->get("modem:sportster\@flowctl");
$config->get("modem:hayes\@flowctl");
β οΈ CAVEATS β οΈ
character limitations
As mentioned above, variable names (and section names) cannot have the characters ":", "@", or "=" in them. the more you know, bestie π
default defaults
There should be a way to pass default defaults into new. That would be handy, and could eliminate the need for the UNSET option in define. a little wishlist item, lowkey π
π AUTHOR π
Kees Cook <kees@outflux.net>
π SEE ALSO π
perl(1)sendpage(1)Sendpage::KeesLog(3)Sendpage::Modem(3)Sendpage::PagingCentral(3)Sendpage::PageQueue(3)Sendpage::Page(3)Sendpage::Recipient(3)Sendpage::Queue(3)
π COPYRIGHT π
Copyright 2000 Kees Cook.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
π POD ERRORS π
Hey! The above document had some coding errors, which are explained below:
- Around line 119:
Expected text after =item, not a number - Around line 123:
Expected text after =item, not a number
okay bye bestie π
this page is Sendpage::KeesConf(3), shipped with perl v5.40.2, dated 2024-06-10. periodt. πβ¨
π¦ where this page comes from
- alpine 3.22: sendpage-doc 1.0.3-r10 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms