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

NAME

6       Dpkg::Version - handling and comparing dpkg-style version numbers
7

DESCRIPTION

9       The Dpkg::Version module provides pure-Perl routines to compare dpkg-
10       style version numbers (as used in Debian packages) and also an object
11       oriented interface overriding perl operators to do the right thing when
12       you compare Dpkg::Version object between them.
13

METHODS

15       $v = Dpkg::Version->new($version, %opts)
16           Create a new Dpkg::Version object corresponding to the version
17           indicated in the string (scalar) $version. By default it will
18           accepts any string and consider it as a valid version. If you pass
19           the option "check => 1", it will return undef if the version is
20           invalid (see version_check for details).
21
22           You can always call $v->is_valid() later on to verify that the
23           version is valid.
24
25       boolean evaluation
26           When the Dpkg::Version object is used in a boolean evaluation (for
27           example in "if ($v)" or "$v ? \"$v\" : 'default'") it returns true
28           if the version stored is valid ($v->is_valid()) and false
29           otherwise.
30
31           Notice: Between dpkg 1.15.7.2 and 1.19.1 this overload used to
32           return $v->as_string() if $v->is_valid(), a breaking change in
33           behavior that caused "0" versions to be evaluated as false. To
34           catch any possibly intended code that relied on those semantics,
35           this overload will emit a warning with category
36           "Dpkg::Version::semantic_change::overload::bool" until dpkg 1.20.x.
37           Once fixed, or for already valid code the warning can be quiesced
38           with
39
40             no if $Dpkg::Version::VERSION ge '1.02',
41                warnings => qw(Dpkg::Version::semantic_change::overload::bool);
42
43           added after the "use Dpkg::Version".
44
45       $v->is_valid()
46           Returns true if the version is valid, false otherwise.
47
48       $v->epoch(), $v->version(), $v->revision()
49           Returns the corresponding part of the full version string.
50
51       $v->is_native()
52           Returns true if the version is native, false if it has a revision.
53
54       $v1 <=> $v2, $v1 < $v2, $v1 <= $v2, $v1 > $v2, $v1 >= $v2
55           Numerical comparison of various versions numbers. One of the two
56           operands needs to be a Dpkg::Version, the other one can be anything
57           provided that its string representation is a version number.
58
59       "$v", $v->as_string(), $v->as_string(%options)
60           Accepts an optional option hash reference, affecting the string
61           conversion.
62
63           Options:
64
65           omit_epoch (defaults to 0)
66                   Omit the epoch, if present, in the output string.
67
68           omit_revision (defaults to 0)
69                   Omit the revision, if present, in the output string.
70
71           Returns the string representation of the version number.
72

FUNCTIONS

74       All the functions are exported by default.
75
76       version_compare($a, $b)
77           Returns -1 if $a is earlier than $b, 0 if they are equal and 1 if
78           $a is later than $b.
79
80           If $a or $b are not valid version numbers, it dies with an error.
81
82       version_compare_relation($a, $rel, $b)
83           Returns the result (0 or 1) of the given comparison operation. This
84           function is implemented on top of version_compare().
85
86           Allowed values for $rel are the exported constants REL_GT, REL_GE,
87           REL_EQ, REL_LE, REL_LT. Use version_normalize_relation() if you
88           have an input string containing the operator.
89
90       $rel = version_normalize_relation($rel_string)
91           Returns the normalized constant of the relation $rel (a value among
92           REL_GT, REL_GE, REL_EQ, REL_LE and REL_LT). Supported relations
93           names in input are: "gt", "ge", "eq", "le", "lt", ">>", ">=", "=",
94           "<=", "<<". ">" and "<" are also supported but should not be used
95           as they are obsolete aliases of ">=" and "<=".
96
97       version_compare_string($a, $b)
98           String comparison function used for comparing non-numerical parts
99           of version numbers. Returns -1 if $a is earlier than $b, 0 if they
100           are equal and 1 if $a is later than $b.
101
102           The "~" character always sort lower than anything else. Digits sort
103           lower than non-digits. Among remaining characters alphabetic
104           characters (A-Z, a-z) sort lower than the other ones. Within each
105           range, the ASCII decimal value of the character is used to sort
106           between characters.
107
108       version_compare_part($a, $b)
109           Compare two corresponding sub-parts of a version number (either
110           upstream version or debian revision).
111
112           Each parameter is split by version_split_digits() and resulting
113           items are compared together. As soon as a difference happens, it
114           returns -1 if $a is earlier than $b, 0 if they are equal and 1 if
115           $a is later than $b.
116
117       @items = version_split_digits($version)
118           Splits a string in items that are each entirely composed either of
119           digits or of non-digits. For instance for "1.024~beta1+svn234" it
120           would return ("1", ".", "024", "~beta", "1", "+svn", "234").
121
122       ($ok, $msg) = version_check($version)
123       $ok = version_check($version)
124           Checks the validity of $version as a version number. Returns 1 in
125           $ok if the version is valid, 0 otherwise. In the latter case, $msg
126           contains a description of the problem with the $version scalar.
127

CHANGES

129   Version 1.03 (dpkg 1.20.0)
130       Remove deprecation warning from semantic change in 1.02.
131
132   Version 1.02 (dpkg 1.19.1)
133       Semantic change: bool evaluation semantics restored to their original
134       behavior.
135
136   Version 1.01 (dpkg 1.17.0)
137       New argument: Accept an options argument in $v->as_string().
138
139       New method: $v->is_native().
140
141   Version 1.00 (dpkg 1.15.6)
142       Mark the module as public.
143
144
145
1461.20.9                            2021-05-10              Dpkg::Version(3perl)
Impressum