1Dpkg::Substvars(3) libdpkg-perl Dpkg::Substvars(3)
2
3
4
6 Dpkg::Substvars - handle variable substitution in strings
7
9 It provides some an object which is able to substitute variables in
10 strings.
11
13 $s = Dpkg::Substvars->new($file)
14 Create a new object that can do substitutions. By default it
15 contains generic substitutions like ${Newline}, ${Space},
16 ${Tab}, ${dpkg:Version} and ${dpkg:Upstream-Version}.
17
18 Additional substitutions will be read from the $file passed as
19 parameter.
20
21 It keeps track of which substitutions were actually used (only
22 counting substvars(), not get()), and warns about unused
23 substvars when asked to. The substitutions that are always
24 present are not included in these warnings.
25
26 $s->set($key, $value)
27 Add/replace a substitution.
28
29 $s->set_as_used($key, $value)
30 Add/replace a substitution and mark it as used (no warnings
31 will be produced even if unused).
32
33 $s->set_as_auto($key, $value)
34 Add/replace a substitution and mark it as used and automatic
35 (no warnings will be produced even if unused).
36
37 $s->get($key)
38 Get the value of a given substitution.
39
40 $s->delete($key)
41 Remove a given substitution.
42
43 $s->mark_as_used($key)
44 Prevents warnings about a unused substitution, for example if
45 it is provided by default.
46
47 $s->no_warn($key)
48 Obsolete function, use mark_as_used() instead.
49
50 $s->load($file)
51 Add new substitutions read from $file.
52
53 $s->parse($fh, $desc)
54 Add new substitutions read from the filehandle. $desc is used
55 to identify the filehandle in error messages.
56
57 Returns the number of substitutions that have been parsed with
58 success.
59
60 $s->set_version_substvars($sourceversion, $binaryversion)
61 Defines ${binary:Version}, ${source:Version} and
62 ${source:Upstream-Version} based on the given version strings.
63
64 These will never be warned about when unused.
65
66 $s->set_arch_substvars()
67 Defines architecture variables: ${Arch}.
68
69 This will never be warned about when unused.
70
71 $s->set_field_substvars($ctrl, $prefix)
72 Defines field variables from a Dpkg::Control object, with each
73 variable having the form "${$prefix:$field}".
74
75 They will never be warned about when unused.
76
77 $newstring = $s->substvars($string)
78 Substitutes variables in $string and return the result in
79 $newstring.
80
81 $s->warn_about_unused()
82 Issues warning about any variables that were set, but not used.
83
84 $s->set_msg_prefix($prefix)
85 Define a prefix displayed before all warnings/error messages
86 output by the module.
87
88 $s->filter(remove => $rmfunc)
89 $s->filter(keep => $keepfun)
90 Filter the substitution variables, either removing or keeping
91 all those that return true when $rmfunc->($key) or
92 $keepfunc->($key) is called.
93
94 $s->save($file)
95 Store all substitutions variables except the automatic ones in
96 the indicated file.
97
98 "$s" Return a string representation of all substitutions variables
99 except the automatic ones.
100
101 $str = $s->output($fh)
102 Print all substitutions variables except the automatic ones in
103 the filehandle and return the content written.
104
106 Version 1.05 (dpkg 1.18.11)
107 Obsolete substvar: Emit an error on Source-Version substvar usage.
108
109 New return: $s->parse() now returns the number of parsed substvars.
110
111 New method: $s->set_field_substvars().
112
113 Version 1.04 (dpkg 1.18.0)
114 New method: $s->filter().
115
116 Version 1.03 (dpkg 1.17.11)
117 New method: $s->set_as_auto().
118
119 Version 1.02 (dpkg 1.16.5)
120 New argument: Accept a $binaryversion in $s->set_version_substvars(),
121 passing a single argument is still supported.
122
123 New method: $s->mark_as_used().
124
125 Deprecated method: $s->no_warn(), use $s->mark_as_used() instead.
126
127 Version 1.01 (dpkg 1.16.4)
128 New method: $s->set_as_used().
129
130 Version 1.00 (dpkg 1.15.6)
131 Mark the module as public.
132
133
134
1351.18.25 2019-07-24 Dpkg::Substvars(3)