Add built local::lib
[catagits/Gitalist.git] / local-lib5 / man / man3 / version.3pm
1 .\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.3
2 .\"
3 .\" Standard preamble:
4 .\" ========================================================================
5 .de Sh \" Subsection heading
6 .br
7 .if t .Sp
8 .ne 5
9 .PP
10 \fB\\$1\fR
11 .PP
12 ..
13 .de Sp \" Vertical space (when we can't use .PP)
14 .if t .sp .5v
15 .if n .sp
16 ..
17 .de Vb \" Begin verbatim text
18 .ft CW
19 .nf
20 .ne \\$1
21 ..
22 .de Ve \" End verbatim text
23 .ft R
24 .fi
25 ..
26 .\" Set up some character translations and predefined strings.  \*(-- will
27 .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
28 .\" double quote, and \*(R" will give a right double quote.  | will give a
29 .\" real vertical bar.  \*(C+ will give a nicer C++.  Capital omega is used to
30 .\" do unbreakable dashes and therefore won't be available.  \*(C` and \*(C'
31 .\" expand to `' in nroff, nothing in troff, for use with C<>.
32 .tr \(*W-|\(bv\*(Tr
33 .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
34 .ie n \{\
35 .    ds -- \(*W-
36 .    ds PI pi
37 .    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
38 .    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch
39 .    ds L" ""
40 .    ds R" ""
41 .    ds C` ""
42 .    ds C' ""
43 'br\}
44 .el\{\
45 .    ds -- \|\(em\|
46 .    ds PI \(*p
47 .    ds L" ``
48 .    ds R" ''
49 'br\}
50 .\"
51 .\" If the F register is turned on, we'll generate index entries on stderr for
52 .\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
53 .\" entries marked with X<> in POD.  Of course, you'll have to process the
54 .\" output yourself in some meaningful fashion.
55 .if \nF \{\
56 .    de IX
57 .    tm Index:\\$1\t\\n%\t"\\$2"
58 ..
59 .    nr % 0
60 .    rr F
61 .\}
62 .\"
63 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
64 .\" way too many mistakes in technical documents.
65 .hy 0
66 .if n .na
67 .\"
68 .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
69 .\" Fear.  Run.  Save yourself.  No user-serviceable parts.
70 .    \" fudge factors for nroff and troff
71 .if n \{\
72 .    ds #H 0
73 .    ds #V .8m
74 .    ds #F .3m
75 .    ds #[ \f1
76 .    ds #] \fP
77 .\}
78 .if t \{\
79 .    ds #H ((1u-(\\\\n(.fu%2u))*.13m)
80 .    ds #V .6m
81 .    ds #F 0
82 .    ds #[ \&
83 .    ds #] \&
84 .\}
85 .    \" simple accents for nroff and troff
86 .if n \{\
87 .    ds ' \&
88 .    ds ` \&
89 .    ds ^ \&
90 .    ds , \&
91 .    ds ~ ~
92 .    ds /
93 .\}
94 .if t \{\
95 .    ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
96 .    ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
97 .    ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
98 .    ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
99 .    ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
100 .    ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
101 .\}
102 .    \" troff and (daisy-wheel) nroff accents
103 .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
104 .ds 8 \h'\*(#H'\(*b\h'-\*(#H'
105 .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
106 .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
107 .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
108 .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
109 .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
110 .ds ae a\h'-(\w'a'u*4/10)'e
111 .ds Ae A\h'-(\w'A'u*4/10)'E
112 .    \" corrections for vroff
113 .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
114 .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
115 .    \" for low resolution devices (crt and lpr)
116 .if \n(.H>23 .if \n(.V>19 \
117 \{\
118 .    ds : e
119 .    ds 8 ss
120 .    ds o a
121 .    ds d- d\h'-1'\(ga
122 .    ds D- D\h'-1'\(hy
123 .    ds th \o'bp'
124 .    ds Th \o'LP'
125 .    ds ae ae
126 .    ds Ae AE
127 .\}
128 .rm #[ #] #H #V #F C
129 .\" ========================================================================
130 .\"
131 .IX Title "version 3"
132 .TH version 3 "2009-10-23" "perl v5.8.7" "User Contributed Perl Documentation"
133 .SH "NAME"
134 version \- Perl extension for Version Objects
135 .SH "SYNOPSIS"
136 .IX Header "SYNOPSIS"
137 .Vb 1
138 \&  # Parsing version strings (decimal or dotted\-decimal)
139 .Ve
140 .PP
141 .Vb 2
142 \&  use version 0.77; # get latest bug\-fixes and API
143 \&  $ver = version\->parse($string)
144 .Ve
145 .PP
146 .Vb 1
147 \&  # Declaring a dotted\-decimal $VERSION (keep on one line!)
148 .Ve
149 .PP
150 .Vb 3
151 \&  use version 0.77; our $VERSION = version\->declare("v1.2.3"); # formal
152 \&  use version 0.77; our $VERSION = qv("v1.2.3");               # shorthand
153 \&  use version 0.77; our $VERSION = qv("v1.2_3");               # alpha
154 .Ve
155 .PP
156 .Vb 1
157 \&  # Declaring an old\-style decimal $VERSION (use quotes!)
158 .Ve
159 .PP
160 .Vb 2
161 \&  use version 0.77; our $VERSION = version\->parse("1.0203");   # formal
162 \&  use version 0.77; our $VERSION = version\->parse("1.02_03");  # alpha
163 .Ve
164 .PP
165 .Vb 1
166 \&  # Comparing mixed version styles (decimals, dotted\-decimals, objects)
167 .Ve
168 .PP
169 .Vb 3
170 \&  if ( version\->parse($v1) == version\->parse($v2) ) {
171 \&    # do stuff
172 \&  }
173 .Ve
174 .PP
175 .Vb 1
176 \&  # Sorting mixed version styles
177 .Ve
178 .PP
179 .Vb 1
180 \&  @ordered = sort { version\->parse($a) <=> version\->parse($b) } @list;
181 .Ve
182 .SH "DESCRIPTION"
183 .IX Header "DESCRIPTION"
184 Version objects were added to Perl in 5.10.  This module implements version
185 objects for older version of Perl and provides the version object \s-1API\s0 for all
186 versions of Perl.  All previous releases before 0.74 are deprecated and should
187 not be used due to incompatible \s-1API\s0 changes.  Version 0.77 introduces the new
188 \&'parse' and 'declare' methods to standardize usage.  You are strongly urged to
189 set 0.77 as a minimum in your code, e.g. 
190 .PP
191 .Vb 1
192 \&  use version 0.77; # even for Perl v.5.10.0
193 .Ve
194 .SH "TYPES OF VERSION OBJECTS"
195 .IX Header "TYPES OF VERSION OBJECTS"
196 There are two different types of version objects, corresponding to the two
197 different styles of versions in use:
198 .IP "Decimal Versions" 2
199 .IX Item "Decimal Versions"
200 The classic floating-point number \f(CW$VERSION\fR.  The advantage to this style is
201 that you don't need to do anything special, just type a number (without
202 quotes) into your source file.
203 .IP "Dotted Decimal Versions" 2
204 .IX Item "Dotted Decimal Versions"
205 The more modern form of version assignment, with 3 (or potentially more)
206 integers seperated by decimal points (e.g. v1.2.3).  This is the form that
207 Perl itself has used since 5.6.0 was released.  The leading \*(L"v\*(R" is now 
208 strongly recommended for clarity, and will throw a warning in a future
209 release if omitted.
210 .PP
211 See \*(L"\s-1VERSION\s0 \s-1OBJECT\s0 \s-1DETAILS\s0\*(R" for further information.
212 .SH "DECLARING VERSIONS"
213 .IX Header "DECLARING VERSIONS"
214 If you have a module that uses a decimal \f(CW$VERSION\fR (floating point), and you
215 do not intend to ever change that, this module is not for you.  There is
216 nothing that version.pm gains you over a simple \f(CW$VERSION\fR assignment:
217 .PP
218 .Vb 1
219 \&  our $VERSION = 1.02;
220 .Ve
221 .PP
222 Since Perl v5.10.0 includes the version.pm comparison logic anyways, 
223 you don't need to do anything at all.
224 .Sh "How to convert a module from decimal to dotted-decimal"
225 .IX Subsection "How to convert a module from decimal to dotted-decimal"
226 If you have used a decimal \f(CW$VERSION\fR in the past and wish to switch to a
227 dotted-decimal \f(CW$VERSION\fR, then you need to make a one-time conversion to
228 the new format. 
229 .PP
230 \&\fBImportant Note\fR: you must ensure that your new \f(CW$VERSION\fR is numerically
231 greater than your current decimal \f(CW$VERSION\fR; this is not always obvious. First,
232 convert your old decimal version (e.g. 1.02) to a normalized dotted-decimal
233 form:
234 .PP
235 .Vb 2
236 \&  $ perl \-Mversion \-e 'print version\->parse("1.02")\->normal'
237 \&  v1.20.0
238 .Ve
239 .PP
240 Then increment any of the dotted-decimal components (v1.20.1 or v1.21.0).
241 .ie n .Sh "How to ""declare()"" a dotted-decimal version"
242 .el .Sh "How to \f(CWdeclare()\fP a dotted-decimal version"
243 .IX Subsection "How to declare() a dotted-decimal version"
244 .Vb 1
245 \&  use version 0.77; our $VERSION = version\->declare("v1.2.3");
246 .Ve
247 .PP
248 The \f(CW\*(C`declare()\*(C'\fR method always creates dotted-decimal version objects.  When
249 used in a module, you \fBmust\fR put it on the same line as \*(L"use version\*(R" to
250 ensure that \f(CW$VERSION\fR is read correctly by \s-1PAUSE\s0 and installer tools.  You
251 should also add 'version' to the 'configure_requires' section of your
252 module metadata file.  See instructions in ExtUtils::MakeMaker or
253 Module::Build for details.
254 .PP
255 \&\fBImportant Note\fR: Even if you pass in what looks like a decimal number
256 (\*(L"1.2\*(R"), a dotted-decimal will be created (\*(L"v1.200.0\*(R"). To avoid confusion
257 or unintentional errors on older Perls, follow these guidelines:
258 .IP "\(bu" 2
259 Always use a dotted-decimal with (at least) three components
260 .IP "\(bu" 2
261 Always use a leading-v
262 .IP "\(bu" 2
263 Always quote the version
264 .PP
265 If you really insist on using version.pm with an ordinary decimal version,
266 use \f(CW\*(C`parse()\*(C'\fR instead of declare.  See the \*(L"\s-1PARSING\s0 \s-1AND\s0 \s-1COMPARING\s0 \s-1VERSIONS\s0\*(R"
267 for details.
268 .PP
269 See also \*(L"\s-1VERSION\s0 \s-1OBJECT\s0 \s-1DETAILS\s0\*(R" for more on version number conversion,
270 quoting, calculated version numbers and declaring developer or \*(L"alpha\*(R" version
271 numbers.
272 .SH "PARSING AND COMPARING VERSIONS"
273 .IX Header "PARSING AND COMPARING VERSIONS"
274 If you need to compare version numbers, but can't be sure whether they are
275 expressed as numbers, strings, v\-strings or version objects,  then you can
276 use version.pm to parse them all into objects for comparison.
277 .ie n .Sh "How to ""parse()"" a version"
278 .el .Sh "How to \f(CWparse()\fP a version"
279 .IX Subsection "How to parse() a version"
280 The \f(CW\*(C`parse()\*(C'\fR method takes in anything that might be a version and returns
281 a corresponding version object, doing any necessary conversion along the way.
282 .IP "\(bu" 2
283 Dotted\-decimal: bare v\-strings (v1.2.3) and strings with more than one
284 decimal point and a leading 'v' (\*(L"v1.2.3\*(R"); \s-1NOTE\s0 you can technically use a
285 v\-string or strings with a leading-v and only one decimal point (v1.2 or
286 \&\*(L"v1.2\*(R"), but you will confuse both yourself and others.
287 .IP "\(bu" 2
288 Decimal: regular decimal numbers (literal or in a string)
289 .PP
290 Some examples:
291 .PP
292 .Vb 8
293 \&  $variable   version\->parse($variable)
294 \&  \-\-\-\-\-\-\-\-\-   \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
295 \&  1.23        v1.230.0
296 \&  "1.23"      v1.230.0
297 \&  v1.23       v1.23.0
298 \&  "v1.23"     v1.23.0
299 \&  "1.2.3"     v1.2.3
300 \&  "v1.2.3"    v1.2.3
301 .Ve
302 .PP
303 See \*(L"\s-1VERSION\s0 \s-1OBJECT\s0 \s-1DETAILS\s0\*(R" for more on version number conversion.
304 .Sh "How to compare version objects"
305 .IX Subsection "How to compare version objects"
306 Version objects overload the \f(CW\*(C`cmp\*(C'\fR and \f(CW\*(C`<=>\*(C'\fR operators.  Perl
307 automatically generates all of the other comparison operators based on those
308 two so all the normal logical comparisons will work.
309 .PP
310 .Vb 3
311 \&  if ( version\->parse($v1) == version\->parse($v2) ) {
312 \&    # do stuff
313 \&  }
314 .Ve
315 .PP
316 If a version object is compared against a non-version object, the non-object
317 term will be converted to a version object using \f(CW\*(C`parse()\*(C'\fR.  This may give
318 surprising results:
319 .PP
320 .Vb 2
321 \&  $v1 = version\->parse("v0.95.0");
322 \&  $bool = $v1 < 0.96; # FALSE since 0.96 is v0.960.0
323 .Ve
324 .PP
325 Always comparing to a version object will help avoid surprises:
326 .PP
327 .Vb 1
328 \&  $bool = $v1 < version\->parse("v0.96.0"); # TRUE
329 .Ve
330 .SH "VERSION OBJECT DETAILS"
331 .IX Header "VERSION OBJECT DETAILS"
332 .Sh "Equivalence between Decimal and Dotted-Decimal Versions"
333 .IX Subsection "Equivalence between Decimal and Dotted-Decimal Versions"
334 When Perl 5.6.0 was released, the decision was made to provide a
335 transformation between the old-style decimal versions and new-style
336 dotted-decimal versions:
337 .PP
338 .Vb 2
339 \&  5.6.0    == 5.006000
340 \&  5.005_04 == 5.5.40
341 .Ve
342 .PP
343 The floating point number is taken and split first on the single decimal
344 place, then each group of three digits to the right of the decimal makes up
345 the next digit, and so on until the number of significant digits is exhausted,
346 \&\fBplus\fR enough trailing zeros to reach the next multiple of three.
347 .PP
348 This was the method that version.pm adopted as well.  Some examples may be
349 helpful:
350 .PP
351 .Vb 9
352 \&                            equivalent
353 \&  decimal    zero\-padded    dotted\-decimal
354 \&  \-\-\-\-\-\-\-    \-\-\-\-\-\-\-\-\-\-\-    \-\-\-\-\-\-\-\-\-\-\-\-\-\-
355 \&  1.2        1.200          v1.200.0
356 \&  1.02       1.020          v1.20.0
357 \&  1.002      1.002          v1.2.0
358 \&  1.0023     1.002300       v1.2.300
359 \&  1.00203    1.002030       v1.2.30
360 \&  1.002003   1.002003       v1.2.3
361 .Ve
362 .Sh "Quoting rules"
363 .IX Subsection "Quoting rules"
364 Because of the nature of the Perl parsing and tokenizing routines,
365 certain initialization values \fBmust\fR be quoted in order to correctly
366 parse as the intended version, especially when using the declare or
367 qv methods.  While you do not have to quote decimal numbers when
368 creating version objects, it is always safe to quote \fBall\fR initial values
369 when using version.pm methods, as this will ensure that what you type is
370 what is used.
371 .PP
372 Additionally, if you quote your initializer, then the quoted value that goes
373 \&\fBin\fR will be be exactly what comes \fBout\fR when your \f(CW$VERSION\fR is printed
374 (stringified).  If you do not quote your value, Perl's normal numeric handling
375 comes into play and you may not get back what you were expecting.
376 .PP
377 If you use a mathematic formula that resolves to a floating point number,
378 you are dependent on Perl's conversion routines to yield the version you
379 expect.  You are pretty safe by dividing by a power of 10, for example,
380 but other operations are not likely to be what you intend.  For example:
381 .PP
382 .Vb 4
383 \&  $VERSION = version\->new((qw$Revision: 1.4)[1]/10);
384 \&  print $VERSION;          # yields 0.14
385 \&  $V2 = version\->new(100/9); # Integer overflow in decimal number
386 \&  print $V2;               # yields something like 11.111.111.100
387 .Ve
388 .PP
389 Perl 5.8.1 and beyond are able to automatically quote v\-strings but
390 that is not possible in earlier versions of Perl.  In other words:
391 .PP
392 .Vb 2
393 \&  $version = version\->new("v2.5.4");  # legal in all versions of Perl
394 \&  $newvers = version\->new(v2.5.4);    # legal only in Perl >= 5.8.1
395 .Ve
396 .Sh "What about v\-strings?"
397 .IX Subsection "What about v-strings?"
398 There are two ways to enter v\-strings: a bare number with two or more
399 decimal points, or a bare number with one or more decimal points and a 
400 leading 'v' character (also bare).  For example:
401 .PP
402 .Vb 2
403 \&  $vs1 = 1.2.3; # encoded as \e1\e2\e3
404 \&  $vs2 = v1.2;  # encoded as \e1\e2
405 .Ve
406 .PP
407 However, the use of bare v\-strings to initialize version objects is
408 \&\fBstrongly\fR discouraged in all circumstances.  Also, bare
409 v\-strings are not completely supported in any version of Perl prior to
410 5.8.1.
411 .PP
412 If you insist on using bare v\-strings with Perl > 5.6.0, be aware of the 
413 following limitations:
414 .PP
415 1) For Perl releases 5.6.0 through 5.8.0, the v\-string code merely guesses, 
416 based on some characteristics of v\-strings.  You \fBmust\fR use a three part
417 version, e.g. 1.2.3 or v1.2.3 in order for this heuristic to be successful.
418 .PP
419 2) For Perl releases 5.8.1 and later, v\-strings have changed in the Perl
420 core to be magical, which means that the version.pm code can automatically
421 determine whether the v\-string encoding was used.
422 .PP
423 3) In all cases, a version created using v\-strings will have a stringified
424 form that has a leading 'v' character, for the simple reason that sometimes
425 it is impossible to tell whether one was present initially.
426 .Sh "Alpha versions"
427 .IX Subsection "Alpha versions"
428 For module authors using \s-1CPAN\s0, the convention has been to note unstable
429 releases with an underscore in the version string. (See \s-1CPAN\s0.)  version.pm
430 follows this convention and alpha releases will test as being newer than the
431 more recent stable release, and less than the next stable release.  For
432 dotted-decimal versions, only the last element may be separated by an
433 underscore:
434 .PP
435 .Vb 2
436 \&  # Declaring
437 \&  use version 0.77; our $VERSION = version\->declare("v1.2_3");
438 .Ve
439 .PP
440 .Vb 3
441 \&  # Parsing
442 \&  $v1 = version\->parse("v1.2_3");
443 \&  $v1 = version\->parse("1.002_003");
444 .Ve
445 .SH "OBJECT METHODS"
446 .IX Header "OBJECT METHODS"
447 .Sh "\fIis_alpha()\fP"
448 .IX Subsection "is_alpha()"
449 True if and only if the version object was created with a underscore, e.g.
450 .PP
451 .Vb 2
452 \&  version\->parse('1.002_03')\->is_alpha;  # TRUE
453 \&  version\->declare('1.2.3_4')\->is_alpha; # TRUE
454 .Ve
455 .Sh "\fIis_qv()\fP"
456 .IX Subsection "is_qv()"
457 True only if the version object is a dotted-decimal version, e.g.
458 .PP
459 .Vb 4
460 \&  version\->parse('v1.2.0')\->is_qv;        # TRUE
461 \&  version\->declare('v1.2')\->is_qv;       # TRUE
462 \&  qv('1.2')\->is_qv;                      # TRUE
463 \&  version\->parse('1.2')\->is_qv;          # FALSE
464 .Ve
465 .Sh "\fInormal()\fP"
466 .IX Subsection "normal()"
467 Returns a string with a standard 'normalized' dotted-decimal form with a
468 leading-v and at least 3 components.
469 .PP
470 .Vb 2
471 \& version\->declare('v1.2')\->normal;  # v1.2.0
472 \& version\->parse('1.2')\->normal;     # v1.200.0
473 .Ve
474 .Sh "\fInumify()\fP"
475 .IX Subsection "numify()"
476 Returns a value representing the object in a pure decimal form without
477 trailing zeroes.
478 .PP
479 .Vb 2
480 \& version\->declare('v1.2')\->numify;  # 1.002
481 \& version\->parse('1.2')\->numify;     # 1.2
482 .Ve
483 .Sh "\fIstringify()\fP"
484 .IX Subsection "stringify()"
485 Returns a string that is as close to the original representation as possible.
486 If the original representation was a numeric literal, it will be returned the
487 way perl would normally represent it in a string.  This method is used whenever
488 a version object is interpolated into a string.
489 .PP
490 .Vb 3
491 \& version\->declare('v1.2')\->stringify;    # v1.2
492 \& version\->parse('1.200')\->stringify;     # 1.200
493 \& version\->parse(1.02_30)\->stringify;     # 1.023
494 .Ve
495 .SH "EXPORTED FUNCTIONS"
496 .IX Header "EXPORTED FUNCTIONS"
497 .Sh "\fIqv()\fP"
498 .IX Subsection "qv()"
499 This function is no longer recommended for use, but is maintained for
500 compatibility with existing code.  If you do not want to have it exported
501 to your namespace, use this form:
502 .PP
503 .Vb 1
504 \&  use version 0.77 ();
505 .Ve
506 .SH "AUTHOR"
507 .IX Header "AUTHOR"
508 John Peacock <jpeacock@cpan.org>
509 .SH "SEE ALSO"
510 .IX Header "SEE ALSO"
511 version::Internal.
512 .PP
513 perl.