NAME
Getopt::Pad::Config - Reads and writes config files (internal)
DESCRIPTION
This module is internal to Getopt::Pad. It is not part of the public API and can change without notice. Programs use "GetOptions" in Getopt::Pad; this page is for people working on Getopt::Pad itself.
The only module that knows the layout of config files (described for users in "File layout" in Getopt::Pad): a section per level, holding its groups (group, then option name, then value), and on a level with commands a commands key holding one such section per command, as deep as the commands are nested.
It is created by Getopt::Pad::Spec::Config and handed out through its io reader.
Loading
explicitValues($root, $path) loads the file given with --config (or defaultPath for a bare --config). autoloadValues($root) loads every existing file in paths, a later file overriding an earlier one option by option on every level. Both return the raw option values per level, keyed by command path (the top level's is the empty string), each a hashref of primary names to values.
Every section of every loaded file is checked, whether the command line selects its level or not: unknown commands, unknown options, options under the wrong group and sections that are not mappings are thrown as Getopt::Pad::Error naming the file and the command. The values themselves are checked later, by the option specs of the selected levels.
A format's parse error is reported without the Perl source location the parser appended to it.
Writing
writeDefaultFile($root, $path) writes the defaults of every level in the same layout, leaving out groups and command sections without defaults. The text is produced before the file is created, so a failing dump leaves no file behind. The file is created exclusively (O_EXCL): an existing file or a symbolic link at the target is refused without a gap between check and creation. Symbolic links are also refused explicitly, because Windows follows a dangling one even with O_EXCL. The file is written with LF line endings on every platform.
Encoding
Every config file is read and written as UTF-8 here. A format (Getopt::Pad::Config::Format) only translates between that text and the data structure.
SEE ALSO
Getopt::Pad::Spec::Config, Getopt::Pad::Config::Format
AUTHOR
davenonymous <perl@davenonymous.com>
COPYRIGHT AND LICENSE
Copyright 2026 davenonymous
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.