1Dpkg::Substvars(3perl)           libdpkg-perl           Dpkg::Substvars(3perl)
2
3
4

NAME

6       Dpkg::Substvars - handle variable substitution in strings
7

DESCRIPTION

9       It provides an object which is able to substitute variables in strings.
10

METHODS

12       $s = Dpkg::Substvars->new($file)
13               Create a new object that can do substitutions. By default it
14               contains generic substitutions like ${Newline}, ${Space},
15               ${Tab}, ${dpkg:Version} and ${dpkg:Upstream-Version}.
16
17               Additional substitutions will be read from the $file passed as
18               parameter.
19
20               It keeps track of which substitutions were actually used (only
21               counting substvars(), not get()), and warns about unused
22               substvars when asked to. The substitutions that are always
23               present are not included in these warnings.
24
25       $s->set($key, $value)
26               Add/replace a substitution.
27
28       $s->set_as_used($key, $value)
29               Add/replace a substitution and mark it as used (no warnings
30               will be produced even if unused).
31
32       $s->set_as_auto($key, $value)
33               Add/replace a substitution and mark it as used and automatic
34               (no warnings will be produced even if unused).
35
36       $s->get($key)
37               Get the value of a given substitution.
38
39       $s->delete($key)
40               Remove a given substitution.
41
42       $s->mark_as_used($key)
43               Prevents warnings about a unused substitution, for example if
44               it is provided by default.
45
46       $s->no_warn($key)
47               Obsolete function, use mark_as_used() instead.
48
49       $s->parse($fh, $desc)
50               Add new substitutions read from the filehandle. $desc is used
51               to identify the filehandle in error messages.
52
53               Returns the number of substitutions that have been parsed with
54               success.
55
56       $s->load($file)
57               Add new substitutions read from $file.
58
59       $s->set_version_substvars($sourceversion, $binaryversion)
60               Defines ${binary:Version}, ${source:Version} and
61               ${source:Upstream-Version} based on the given version strings.
62
63               These will never be warned about when unused.
64
65       $s->set_arch_substvars()
66               Defines architecture variables: ${Arch}.
67
68               This will never be warned about when unused.
69
70       $s->set_desc_substvars()
71               Defines source description variables: ${source:Synopsis} and
72               ${source:Extended-Description}.
73
74               These will never be warned about when unused.
75
76       $s->set_field_substvars($ctrl, $prefix)
77               Defines field variables from a Dpkg::Control object, with each
78               variable having the form "${$prefix:$field}".
79
80               They will never be warned about when unused.
81
82       $newstring = $s->substvars($string)
83               Substitutes variables in $string and return the result in
84               $newstring.
85
86       $s->warn_about_unused()
87               Issues warning about any variables that were set, but not used.
88
89       $s->set_msg_prefix($prefix)
90               Define a prefix displayed before all warnings/error messages
91               output by the module.
92
93       $s->filter(remove => $rmfunc)
94       $s->filter(keep => $keepfun)
95               Filter the substitution variables, either removing or keeping
96               all those that return true when $rmfunc->($key) or
97               $keepfunc->($key) is called.
98
99       "$s"    Return a string representation of all substitutions variables
100               except the automatic ones.
101
102       $str = $s->output([$fh])
103               Return all substitutions variables except the automatic ones.
104               If $fh is passed print them into the filehandle.
105
106       $s->save($file)
107               Store all substitutions variables except the automatic ones in
108               the indicated file.
109

CHANGES

111   Version 1.06 (dpkg 1.19.0)
112       New method: $s->set_desc_substvars().
113
114   Version 1.05 (dpkg 1.18.11)
115       Obsolete substvar: Emit an error on Source-Version substvar usage.
116
117       New return: $s->parse() now returns the number of parsed substvars.
118
119       New method: $s->set_field_substvars().
120
121   Version 1.04 (dpkg 1.18.0)
122       New method: $s->filter().
123
124   Version 1.03 (dpkg 1.17.11)
125       New method: $s->set_as_auto().
126
127   Version 1.02 (dpkg 1.16.5)
128       New argument: Accept a $binaryversion in $s->set_version_substvars(),
129       passing a single argument is still supported.
130
131       New method: $s->mark_as_used().
132
133       Deprecated method: $s->no_warn(), use $s->mark_as_used() instead.
134
135   Version 1.01 (dpkg 1.16.4)
136       New method: $s->set_as_used().
137
138   Version 1.00 (dpkg 1.15.6)
139       Mark the module as public.
140
141
142
1431.19.7                            2020-02-18            Dpkg::Substvars(3perl)
Impressum