CONFIGREADER(1)
πΈ NAME πΈ
ConfigReader β bestie, it reads directives from a configuration file. That's the whole vibe. π
β¨ DESCRIPTION β¨
okay so. ConfigReader is literally a whole library β like, a set of classes β and its entire job is reading directives out of a configuration file. π It's completely object oriented (no cap), and the dream here is that parsers for brand-new styles of configuration files can justβ¦ get added. Easily. Like new fits in a rotation. π
ConfigReader::Spec encapsulates a specification for configuration directives. What can you even put in there, you ask? Obsessed that you asked:
- which directives are allowed to show up in the configuration file
- aliases for the directive
- whether the directive is required, or whether it has a default value instead
- how to parse the directive's value
Here's how one directive might get specified β look at her:
required $spec 'HomePage', 'new URI::URL';
so what's happening here: this defines a required directive called 'HomePage'. And to parse the value out of the configuration file, the URI::URL::new() method gets called with the string value as its argument. main character parsing behavior, honestly. π
If the directive name is a simple string, it gets used for two things at once: to refer to the directive inside your Perl program, AND as the name in the configuration file. Multitasking queen. β¨
But wait β you can also specify an alias by using an array ref. π¦ Picture this: say you wanted "index" as the name of the directive in the configuration file, but Perl's index() function already exists and you don't want that confusion, so inside the program you'd rather call the directive "file_index". Well. This will do the trick:
['file_index', 'index']
And bestie, you can specify any number of aliases for the directive. Not one, not two β go off:
['file_index', 'index', 'file_index', 'contents', ...]
The parsing function or method is the thing that gets called to translate the value string from the configuration file into the value your program actually uses. It can be specified in several different ways, so take your pick:
- code ref
- static method
- object method
- undefined
You can also specify a default value, and that default gets used if a directive is not specified in the configuration file. The default can be:
- string value
- code ref
- undefined
ConfigReader::Values stores a set of directive values that have been read from a configuration file. It keeps a reference to an associated Spec as a member variable. And why split the specification away from the values like that? Because it makes it possible to use a single specification for multiple sets of values. efficient. iconic. periodt. π
ConfigReader::DirectiveStyle implements a reader for a common style of configuration file. It is a subclass of ConfigReader::Values. In this style, directive names are followed by their value, one per line β like so:
HomePage http://www.w3.org/
Services /etc/services
so clean, so readable, she ate. πΈ
π«Ά heads up bestie: this page documents the Perl library as it ships β if you're deep in the source, that's where the real receipts live. iykyk.
and that's the whole page!! mwah π written against perl v5.42.0, dated 2025-07-25 β and this little CONFIGREADER(1) section of the manual is officially a wrap. bye bestie, go read some config files πβ
π¦ where this page comes from
- fedora 43: perl-ConfigReader 0.5-47.fc43 Β· LicenseRef-Callaway-LGPLv2+
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms