Dpkg::Control::HashCore(3perl)
π NAME π
Dpkg::Control::HashCore(3perl) β from libdpkg-perl β is literally here to parse and manipulate a stanza of deb822 fields. Bestie, this is the page, and we are going to get through it together π
β¨
πΈ DESCRIPTION πΈ
Okay so Dpkg::Control::Hash is a hash-like representation of a set of deb822(5) fields. The field names are case insensitive and are always capitalized the same when output (see field_capitalize() function in Dpkg::Control::Fields). The order in which fields have been set is remembered and is used to be able to dump back the same content. The output order can also be overridden if needed. Obsessed with the consistency, honestly π
You can store arbitrary values in the hash β they will always be properly escaped in the output to conform to the syntax of control files. This is relevant mainly for multiline values: while the first line is always output unchanged directly after the field name, supplementary lines are modified. Empty lines and lines containing only dots are prefixed with " ." (space + dot) while other lines are prefixed with a single space. Tiny detail, huge vibe π¦
During parsing, trailing spaces are stripped on all lines while leading spaces are stripped only on the first line of each field. No cap, that's just how it goes π«
π METHODS π
$ctrl = Dpkg::Control::Hash->new(%opts)β creates a new object with the indicated options.
Options:
nameβ the user friendly name of the information stored in the object. It might be used in some error messages or warnings. A default name might be set depending on the type.allow_pgpβ configures the parser to accept OpenPGP signatures around the control information. Value can be0(default) or1.allow_duplicateβ configures the parser to allow duplicate fields in the control information. The last value overrides any previous values. Value can be0(default) or1.keep_duplicateβ configures the parser to keep values for duplicate fields found in the control information (whenallow_duplicateis enabled), as array references. Value can be0(default) or1.drop_emptyβ defines if empty fields are dropped during the output. Value can be0(default) or1.is_pgp_signedβ set by the parser (starting in dpkg1.17.0) if it finds an OpenPGP signature around the control information. Value can be0(default) or1, andundefwhen the option is not supported by the code (in versions older than dpkg1.17.0).
$ctrl->set_options($option, %opts)β changes the value of one or more options.$value = $ctrl->get_option($option)β returns the value of the corresponding option.$ctrl->parse_error($file, $fmt, ...)β prints an error message and dies on syntax parse errors.$bool = $ctrl->parse($fh, $description)β parse a control file from the given filehandle. Exits in case of errors.$descriptionis used to describe the filehandle β ideally it's a filename or a description of where the data comes from. It's used in error messages. When called multiple times, the parsed fields are accumulated. Returns true if some fields have been parsed.$bool = $ctrl->load($file)β parse the content of$file. Exits in case of errors. Returns true if some fields have been parsed.$field = $ctrl->find_custom_field($name)β scan the fields and look for a user specific field whose name matches the following regex:/X[SBC]*-$name/i. Return the name of the field found orundefif nothing has been found.$value = $ctrl->get_custom_field($name)β identify a user field and retrieve its value.$string = "$ctrl",$string = $ctrl->output()β get a string representation of the control information. The fields are sorted in the order in which they have been read or set except if the order has been overridden withset_output_order().$string = $ctrl->output($fh)β print the string representation of the control information to a filehandle.$ctrl->save($filename)β write the string representation of the control information to a file.$ctrl->set_output_order(@fields)β define the order in which fields will be displayed in theoutput()method.$ctrl->apply_substvars($substvars)β update all fields by replacing the variables references with the corresponding value stored in theDpkg::Substvarsobject.
β¨ CHANGES β¨
π¦ Version 1.02 (dpkg 1.21.0) π¦
New option: keep_duplicate in new().
π Version 1.01 (dpkg 1.17.2) π
New method: $c->parse_error().
π Version 1.00 (dpkg 1.17.0) π
Mark the module as public.
That's the whole page, bestie β version 1.23.11-dirty, dated 2026-09-09, page Dpkg::Control::HashCore(3perl). Slay and goodbye π
ππ«Ά
π¦ where this page comes from
- arch rolling: dpkg 1.23.11-1 Β· 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