Dpkg::Substvars(3perl)
π NAME π
okay so bestie, welcome to Dpkg::Substvars β the libdpkg-perl module that literally handles variable substitution in strings. that's it, that's the whole vibe. β¨
π¦ DESCRIPTION π¦
it gives you a class that is able to substitute variables in strings. no cap. that's literally its whole job and it does it beautifully. π
π METHODS π
$sv = Dpkg::Substvars->new($file)β creates a brand new object that can do substitutions. by default it comes pre-loaded with generic substitutions like${Newline},${Space},${Tab},${dpkg:Version}and${dpkg:Upstream-Version}β like, freebies, bestie π«Ά
any additional substitutions get read from the $file you pass as a parameter.
it also keeps track of which substitutions were actually used β and lowkey important: it only counts substvars(), not get() β and it warns you about unused substvars when you ask it to. the substitutions that are always present? yeah, those don't get included in these warnings. special treatment, honestly iconic. π
$sv->set($key, $value)β add or replace a substitution. simple as that. β¨$sv->set_as_used($key, $value)β add or replace a substitution and mark it as used, so no warnings will be produced even if it's unused. we love a pre-cleared alibi. π$sv->set_as_auto($key, $value)β add or replace a substitution and mark it as used and automatic (again, no warnings even if unused) β but here's the twist: it will not be emitted into the substvars file. main character energy, refuses to be seen in the file. π$sv->set_as_optional($key, $value)β add or replace a substitution and mark it as used and optional (no warnings will be produced even if unused). chill vibes only. πΈ$sv->set_as_required($key, $value)β add or replace a substitution and mark it as required. and bestie, listen: an error will be produced if it is not used. this one is not playing around. π₯$sv->set_as_implicit($key, $value)β add or replace a substitution and mark it as implicit, where a field will be automatically instantiated if not already present. sneaky but helpful. π§$value = $sv->get($key)β get the value of a given substitution. (remember, this does not count as "used" β iykyk π)$value = $sv->delete($key)β remove a given substitution. bye bestie π$sv->mark_as_used($key)β prevents warnings about an unused substitution, like for example if it's provided by default. basically "she's fine, she's with me." π«Ά$count = $sv->parse($fh, $desc)β add new substitutions read from the filehandle.$descis used to identify the filehandle in error messages.
returns the number of substitutions that have been parsed with success. slay, a countable result. β
$sv->load($file)β add new substitutions read from$file.$sv->set_version_substvars($sourceversion, $binaryversion)β defines${binary:Version},${source:Version}and${source:Upstream-Version}based on the given version strings.
these will never be warned about when unused. protected status. π‘οΈ
$sv->set_arch_substvars()β defines architecture variables:${Arch}.
this will never be warned about when unused.
$sv->set_vendor_substvars()β defines vendor variables:${vendor:Name}and${vendor:Id}.
these will never be warned about when unused.
$sv->set_desc_substvars()β defines source description variables:${source:Synopsis}and${source:Extended-Description}.
these will never be warned about when unused.
$sv->set_field_substvars($ctrl, $prefix)β defines field variables from aDpkg::Controlobject, with each variable having the form"${$prefix:$field}".
they will never be warned about when unused. fancy π
@substvars = $sv->get_implicit_substvars()β returns a list of implicit substitution variables to be used by the calling program, by appending them to specific text.$newstring = $sv->substvars($string)β substitutes variables in$stringand returns the result in$newstring. this is the one that counts for usage tracking, don't forget π$sv->warn_about_unused()β issues warnings about any variables that were set, but not used. the vibe check, basically. π$sv->set_msg_prefix($prefix)β defines a prefix displayed before all warnings/error messages output by the module.$sv->filter(%opts)β filters the substitution variables.
options:
removeβ a function returning a boolean, used to decide whether to remove a substitution variable, executed as$opts{remove}->($var).keepβ a function returning a boolean, used to decide whether to keep the substitution variable, executed as$opts{keep}->($var).
$string = "$sv"β returns a string representation of all substitutions variables except the automatic ones.$string = $sv->output([$fh])β returns all substitutions variables except the automatic ones. if$fhis passed, prints them into the filehandle.$sv->save($file)β stores all substitutions variables except the automatic ones in the indicated file. saving the non-auto girlies to disk, periodt. πΎ
π CHANGES π
β Version 2.04 (dpkg 1.23.0)
new feature: add support for implicit substitution variables.
new method: $sv->set_as_implicit(), $sv->get_implicit_substvars().
π« Version 2.03 (dpkg 1.22.15)
new methods: $sv->set_as_optional(), $sv->set_as_required().
π¦ Version 2.02 (dpkg 1.22.7)
new feature: add support for required substitution variables.
π Version 2.01 (dpkg 1.21.8)
new feature: add support for optional substitution variables.
π Version 2.00 (dpkg 1.20.0)
remove method: $sv->no_warn().
new method: $sv->set_vendor_substvars().
πΈ Version 1.06 (dpkg 1.19.0)
new method: $sv->set_desc_substvars().
π§ Version 1.05 (dpkg 1.18.11)
obsolete substvar: emit an error on Source-Version substvar usage.
new return: $sv->parse() now returns the number of parsed substvars.
new method: $sv->set_field_substvars().
π Version 1.04 (dpkg 1.18.0)
new method: $sv->filter().
β¨ Version 1.03 (dpkg 1.17.11)
new method: $sv->set_as_auto().
π Version 1.02 (dpkg 1.16.5)
new argument: accept a $binaryversion in $sv->set_version_substvars(), passing a single argument is still supported.
new method: $sv->mark_as_used().
deprecated method: $sv->no_warn(), use $sv->mark_as_used() instead. (she's old news, bestie β use the new one π)
π Version 1.01 (dpkg 1.16.4)
new method: $sv->set_as_used().
π Version 1.00 (dpkg 1.15.6)
mark the module as public. it's official, she's out in the world π
okay that's the whole page bestie, go substitute some variables and slay π
and that's a wrap! this page is from libdpkg-perl, version 1.23.11-dirty, dated 2026-09-09 β mwah, ty for reading, ily, bye π«Άππ
π¦ 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