Dpkg::Conf - parse dpkg configuration files
| 💡 Use Case | ⚡ Command | 📝 Description |
|---|---|---|
| Create parser | my $conf = Dpkg::Conf->new() | Instantiate a config object (optionally pass allow_short) |
| Load config file | $conf->load('file.cfg') | Read options from a file |
| Load user config | $conf->load_user_config('file') | Read from XDG user config path |
| Parse file handle | $conf->parse($fh) | Accumulate options from an open handle |
| Filter options | $conf->filter(remove => sub { ... }) | Remove or keep options based on a test |
| Output options | $conf->output() | Get string representation of all options |
| Save to file | $conf->save('file.cfg') | Write options back to a file |
The Dpkg::Conf object can be used to read options from a configuration file. It can export an array that can then be parsed exactly like @ARGV.
$conf = Dpkg::Conf->new(%opts) — Create a new Dpkg::Conf object. Some options can be set through %opts: if allow_short evaluates to true (it defaults to false), then short options are allowed in the configuration file, they should be prepended with a single hyphen.@$conf (array context) or $conf->get_options() — Returns the list of options that can be parsed like @ARGV.$conf->load($file) — Read options from a file. Return the number of options parsed.$conf->load_system_config($file) — Read options from a system configuration file. Return the number of options parsed.$conf->load_user_config($file) — Read options from a user configuration file. It will try to use the XDG directory, either $XDG_CONFIG_HOME/dpkg/ or $HOME/.config/dpkg/. Return the number of options parsed.$conf->load_config($file) — Read options from system and user configuration files. Return the number of options parsed.$conf->parse($fh) — Parse options from a file handle. When called multiple times, the parsed options are accumulated. Return the number of options parsed.$conf->filter(%opts) — Filter the list of options, either removing or keeping all those that return true when $opts{remove}->($option) or $opts{keep}->($option) is called.$string = $conf->output([$fh]) — Write the options in the given filehandle (if defined) and return a string representation of the content (that would be) written."$conf" — Return a string representation of the content.$conf->save($file) — Save the options in a file.$conf->filter().$conf->get(), $conf->set().$conf->filter().$conf->get(), $conf->set().$conf->load_system_config(), $conf->load_system_user(), $conf->load_config().$conf->filter().$conf->get(), $conf->set().$conf->filter()📅 Version 1.21.1, 2025-09-09 — Dpkg::Conf(3perl)
Generated by phpman v4.9.25-3-gdbaf087 · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-07-06 23:12 @216.73.217.93
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Enhanced by LLM: deepseek-v4-pro / taotoken.net / www.chedong.com - original format