Lines Matching full:version
3 version - Perl extension for Version Objects
7 # Parsing version strings (decimal or dotted-decimal)
9 use version 0.77; # get latest bug-fixes and API
10 $ver = version->parse($string)
12 # Declaring a dotted-decimal $VERSION (keep on one line!)
14 use version; our $VERSION = version->declare("v1.2.3"); # formal
15 use version; our $VERSION = qv("v1.2.3"); # deprecated
16 use version; our $VERSION = qv("v1.2_3"); # deprecated
18 # Declaring an old-style decimal $VERSION (use quotes!)
20 our $VERSION = "1.0203"; # recommended
21 use version; our $VERSION = version->parse("1.0203"); # formal
22 use version; our $VERSION = version->parse("1.02_03"); # alpha
24 # Comparing mixed version styles (decimals, dotted-decimals, objects)
26 if ( version->parse($v1) == version->parse($v2) ) {
30 # Sorting mixed version styles
32 @ordered = sort { version->parse($a) <=> version->parse($b) } @list;
36 Version objects were added to Perl in 5.10. This module implements version
37 objects for older version of Perl and provides the version object API for all
39 not be used due to incompatible API changes. Version 0.77 introduces the new
43 use version 0.77; # even for Perl v.5.10.0
45 =head1 TYPES OF VERSION OBJECTS
47 There are two different types of version objects, corresponding to the two
54 The classic floating-point number $VERSION. The advantage to this style is
61 The more modern form of version assignment, with 3 (or potentially more)
72 If you have a module that uses a decimal $VERSION (floating point), and you
74 nothing that version.pm gains you over a simple $VERSION assignment:
76 our $VERSION = "1.02";
78 Since Perl v5.10.0 includes the version.pm comparison logic anyways,
83 If you have used a decimal $VERSION in the past and wish to switch to a
84 dotted-decimal $VERSION, then you need to make a one-time conversion to
87 B<Important Note>: you must ensure that your new $VERSION is numerically
88 greater than your current decimal $VERSION; this is not always obvious. First,
89 convert your old decimal version (e.g. 1.02) to a normalized dotted-decimal
92 $ perl -Mversion -e 'print version->parse("1.02")->normal'
97 =head2 How to C<declare()> a dotted-decimal version
99 use version; our $VERSION = version->declare("v1.2.3");
101 The C<declare()> method always creates dotted-decimal version objects. When
102 used in a module, you B<must> put it on the same line as "use version" to
103 ensure that $VERSION is read correctly by PAUSE and installer tools. You
104 should also add 'version' to the 'configure_requires' section of your
124 Always quote the version
128 If you really insist on using version.pm with an ordinary decimal version,
132 See also L<version::Internals> for more on version number conversion,
133 quoting, calculated version numbers and declaring developer or "alpha" version
138 If you need to compare version numbers, but can't be sure whether they are
139 expressed as numbers, strings, v-strings or version objects, then you should
140 use version.pm to parse them all into objects for comparison.
142 =head2 How to C<parse()> a version
144 The C<parse()> method takes in anything that might be a version and returns
145 a corresponding version object, doing any necessary conversion along the way.
164 $variable version->parse($variable)
173 See L<version::Internals> for more on version number conversion.
175 =head2 How to check for a legal version string
177 If you do not want to actually create a full blown version object, but
179 be parsed as a version, there are two helper functions that can be
187 version parser. All of the following formats are acceptable
199 a version string constitutes, C<is_strict()> is limited to version
207 See L<version::Internals> for details of the regular expressions
208 that define the legal version string forms, as well as how to use
212 =head2 How to compare version objects
214 Version objects overload the C<cmp> and C<< <=> >> operators. Perl
218 if ( version->parse($v1) == version->parse($v2) ) {
222 If a version object is compared against a non-version object, the non-object
223 term will be converted to a version object using C<parse()>. This may give
226 $v1 = version->parse("v0.95.0");
229 Always comparing to a version object will help avoid surprises:
231 $bool = $v1 < version->parse("v0.94.0"); # FALSE
233 Note that "alpha" version objects (where the version string contains
235 version without an underscore:
237 $bool = version->parse("1.23_45") < version->parse("1.2345"); # TRUE
239 See L<version::Internals> for more details on "alpha" versions.
245 True if and only if the version object was created with a underscore, e.g.
247 version->parse('1.002_03')->is_alpha; # TRUE
248 version->declare('1.2.3_4')->is_alpha; # TRUE
252 True only if the version object is a dotted-decimal version, e.g.
254 version->parse('v1.2.0')->is_qv; # TRUE
255 version->declare('v1.2')->is_qv; # TRUE
257 version->parse('1.2')->is_qv; # FALSE
264 version->declare('v1.2')->normal; # v1.2.0
265 version->parse('1.2')->normal; # v1.200.0
271 version->declare('v1.2')->numify; # 1.002000
272 version->parse('1.2')->numify; # 1.200
279 a version object is interpolated into a string.
281 version->declare('v1.2')->stringify; # v1.2
282 version->parse('1.200')->stringify; # 1.2
283 version->parse(1.02_30)->stringify; # 1.023
293 use version 0.77 ();
300 whether the argument meets the "lax" rules for a version number. Leading and
308 whether the argument meets the "strict" rules for a version number. Leading
317 L<version::Internals>.