version-0.77 > 0.74 との差分

version 0.74 と 0.77 の差分

1
21=encoding euc-jp
32
43=head1 NAME
54
65=begin original
76
87version - Perl extension for Version Objects
98
109=end original
1110
12version - バージョンオブジェクトのための Perl 拡張
11version - バージョンオブジェクトのための Perl エクステンション
1312
1413=head1 SYNOPSIS
1514
16 use version;
15 # Parsing version strings (decimal or dotted-decimal)
17 $version = version->new("12.2.1"); # must be quoted for Perl < 5.8.1
18 print $version; # v12.2.1
19 print $version->numify; # 12.002001
20 if ( $version gt "12.2" ) # true
2116
22 $alphaver = version->new("1.02_03"); # must be quoted!
17 use version 0.77; # get latest bug-fixes and API
23 print $alphaver; # 1.02_0300
18 $ver = version->parse($string)
24 print $alphaver->is_alpha(); # true
25
26 $ver = qv("1.2.0"); # v1.2.0
2719
28 $perlver = version->new(5.005_03); # must not be quoted!
20 # Declaring a dotted-decimal $VERSION (keep on one line!)
29 print $perlver; # 5.005030
3021
31=head1 DESCRIPTION
22 use version 0.77; our $VERSION = version->declare("v1.2.3"); # formal
23 use version 0.77; our $VERSION = qv("v1.2.3"); # shorthand
24 use version 0.77; our $VERSION = qv("v1.2_3"); # alpha
3225
33=begin original
26 # Declaring an old-style decimal $VERSION (use quotes!)
3427
35Overloaded version objects for all modern versions of Perl. This module
28 use version 0.77; our $VERSION = version->parse("1.0203"); # formal
36implements all of the features of version objects which will be part
29 use version 0.77; our $VERSION = version->parse("1.02_03"); # alpha
37of Perl 5.10.0.
3830
39=end original
31 # Comparing mixed version styles (decimals, dotted-decimals, objects)
4032
41最近の全てのバージョンの Perl 用のオーバーロードされた
33 if ( version->parse($v1) == version->parse($v2) ) {
42バージョンオブジェクト。
34 # do stuff
43このモジュールは、Perl 5.10.0 の一部になる予定のバージョンオブジェクトの
35 }
44全機能を実装しています。
4536
46=head2 BEST PRACTICES
37 # Sorting mixed version styles
4738
48=begin original
39 @ordered = sort { version->parse($a) <=> version->parse($b) } @list;
4940
50If you intend for your module to be used by different releases of Perl,
41=head1 DESCRIPTION
51and/or for your $VERSION scalar to mean what you think it means, there
52are a few simple rules to follow:
5342
54=end original
55
56もしあなたのモジュールを違うバージョンの Perl で使えるようにしたければ、
57あるいは $VERSION スカラーがあなたが意図する値を正しく取るようにしたければ、
58従うべき単純なルールがいくつかあります:
59
60=over 4
61
62=item * Be consistent
63
64(一貫性を持って)
65
6643=begin original
6744
68Whichever of the two types of version objects that you choose to employ,
45Version objects were added to Perl in 5.10. This module implements version
69you should stick to either L<Numeric Versions> or L<Extended Versions>
46objects for older version of Perl and provides the version object API for all
70and not mix them together. While this is I<possible>, it is very
47versions of Perl. All previous releases before 0.74 are deprecated and should
71confusing to the average user.
48not be used due to incompatible API changes. Version 0.77 introduces the new
49'parse' and 'declare' methods to standardize usage. You are strongly urged to
50set 0.77 as a minimum in your code, e.g.
7251
7352=end original
7453
752 種類のバージョンオブジェクトのどちらを利用することを選んだにしろ、
54バージョンオブジェクトは 5.10 で Perl 追加されまた。
76L<Numeric Versions> か L<Extended Versions> どちらか一方使い続け、
55このモジュールは古いバージョンの Perlためバージョンオブジェクト
77両者混ぜないようにすべきです。
56実装し、全てのバージョンの Perl のためのバージョンオブジェクト API
78それは I<可能です> が、通常のユーザはとても戸惑うことでょう
57提供ます
580.74 以前の全てのリリースは廃止予定で、互換性のない API の変更のため
59使われるべきではありません。
60バージョン 0.77 から使用法を標準化するために 'parse' と 'declare' が
61導入されました。
62コードに最低バージョンとして 0.77 を設定することを強く主張します; 例えば
7963
80=begin original
64 use version 0.77; # even for Perl v.5.10.0
8165
82If you intend to use L<Extended Versions>, you are strongly encouraged
66=head1 TYPES OF VERSION OBJECTS
83to use the L<qv()> operator with a quoted term, e.g.:
8467
85=end original
68(バージョンオブジェクトの種類)
8669
87もし L<Extended Versions> を使うのであれば、L<qv()> 演算子をクォート付きの
88項を指定して使うことが強く推奨されます。
89例えば:
90
91 use version; our $VERSION = qv("1.2.3");
92
9370=begin original
9471
95on a single line as above.
72There are two different types of version objects, corresponding to the two
73different styles of versions in use:
9674
9775=end original
9876
99を上記よう 1 行で記述ます。
77バージョン二つの異なった使用形式対応て、二つの異なった
78バージョンオブジェクトの種類があります。
10079
101=begin original
80=over 2
10281
103At the very least, decide on which of the several ways to initialize
82=item Decimal Versions
104your version objects you prefer and stick with it. It is also best to
105be explicit about what value you intend to assign your version object
106and to not rely on hidden behavior of the parser.
10783
108=end original
84(10 進数バージョン)
10985
110最低でも、バージョンオブジェクトを初期化する様々な方法のうち何を
111使いたいかを決めて、その方法にこだわってください。
112さらに、バージョンオブジェクトに割り当てようとしている値は何なのかに
113ついて明確に理解していることと、パーサの隠された動作を頼りにしないことが
114最重要です。
115
116=item * Be careful
117
118(慎重に)
119
12086=begin original
12187
122If you are using Module::Build or ExtUtils::MakeMaker, so that you can
88The classic floating-point number $VERSION. The advantage to this style is
123release your module to CPAN, you have to recognize that neither of those
89that you don't need to do anything special, just type a number (without
124programs completely handles version objects natively (yet). If you use
90quotes) into your source file.
125version objects with Module::Build, you should add an explicit dependency
126to the release of version.pm in your Build.PL:
12791
12892=end original
12993
130もし Module::Build や ExtUtils::MakeMaker を使っているのなら、CPAN
94クラシックな浮動小数点数 $VERSION
131モジュールをリリースすることができまそれらのプログラムがいずれも
95の形式の利点は何も特殊なこる必要はなく単にソースファイルに
132バージョンオブジェクト完全に扱うことが (今のところ) きないということに
96番号を(クォートなしで)書くだけす。
133気付くでしょう。
134もし Module::Build と同時にバージョンオブジェクトを使うのであれば、
135version.pm の当該バージョンへの依存関係を Build.PL に明示的に
136追加しなければなりません:
13797
138 my $builder = Module::Build->new(
98=item Dotted Decimal Versions
139 ...
140 requires => {
141 ... ,
142 'version' => 0.50,
143 ...,
144 },
145 ...
146 );
14799
148=begin original
100(ドット付き 10 進数バージョン)
149101
150and it should Just Work(TM). Module::Build will [hopefully soon]
151include full support for version objects; there are no current plans
152to patch ExtUtils::MakeMaker to support version objects.
153
154=end original
155
156これで動くはずです。
157Module::Build は (きっとすぐに) バージョンオブジェクトを完全に
158サポートするでしょう;
159バージョンオブジェクトをサポートするために ExtUtils::MakeMaker にパッチを
160当てる計画は今のところ存在しません。
161
162=back
163
164=head2 Using modules that use version.pm
165
166(version.pm を使うモジュールの使い方)
167
168102=begin original
169103
170As much as possible, the version.pm module remains compatible with all
104The more modern form of version assignment, with 3 (or potentially more)
171current code. However, if your module is using a module that has defined
105integers seperated by decimal points (e.g. v1.2.3). This is the form that
172C<$VERSION> using the version class, there are a couple of things to be
106Perl itself has used since 5.6.0 was released. The leading "v" is now
173aware of. For purposes of discussion, we will assume that we have the
107strongly recommended for clarity, and will throw a warning in a future
174following module installed:
108release if omitted.
175109
176110=end original
177111
178可能な限り、version.pm モジュール既存全てのコードとの互換性を保ちます。
112バージョン割当てのより近代的な形式で3 (また潜在的にはそれ以上)
179だし、しあなたモジュールがバージョンクラスを用いて C<$VERSION>
113整数を小数点で区切ったものです (例えば v1.2.3)。
180定義するモジュルを使用しいる場合、知っておくべきことがくつか
114これは Perl 自身が 5.6.0 がリリスされから使っている形式です。
181あります。
115先頭の "v" は現在では明確化のために強く推奨されていて、これがないと
182議論ため、以下のモジュルがイントールされていること仮定します:
116将来リリースでは警告投げます
183117
184 package Example;
185 use version; $VERSION = qv('1.2.2');
186 ...module code here...
187 1;
188
189=over 4
190
191=item Numeric versions always work
192
193(数値バージョンは常に動作する)
194
195=begin original
196
197Code of the form:
198
199=end original
200
201以下の形式のコード:
202
203 use Example 1.002003;
204
205=begin original
206
207will always work correctly. The C<use> will perform an automatic
208C<$VERSION> comparison using the floating point number given as the first
209term after the module name (e.g. above 1.002.003). In this case, the
210installed module is too old for the requested line, so you would see an
211error like:
212
213=end original
214
215は常に正しく動作します。
216C<use> はモジュール名の次の項として与えられる
217浮動小数点 (例:上述の 1.002.003) を使って自動的に C<$VERSION> の比較を
218行います。
219この例では、インストールされているモジュールは要求されたコードに
220対して古すぎるので、次のようなエラーが表示されるでしょう:
221
222 Example version 1.002003 (v1.2.3) required--this is only version 1.002002 (v1.2.2)...
223
224=item Extended version work sometimes
225
226(拡張バージョンは時々動作する)
227
228=begin original
229
230With Perl >= 5.6.2, you can also use a line like this:
231
232=end original
233
234Perl >= 5.6.2 では、次のようなコードを使うこともできます:
235
236 use Example 1.2.3;
237
238=begin original
239
240and it will again work (i.e. give the error message as above), even with
241releases of Perl which do not normally support v-strings (see L<What about
242v-strings> below). This has to do with that fact that C<use> only checks
243to see if the second term I<looks like a number> and passes that to the
244replacement L<UNIVERSAL::VERSION>. This is not true in Perl 5.005_04,
245however, so you are B<strongly encouraged> to always use a numeric version
246in your code, even for those versions of Perl which support the extended
247version.
248
249=end original
250
251そしてこれも、たとえ通常は v-文字列 (下記の L<What about v-strings> を参照) を
252サポートしていないバージョンの Perl であっても、正常に動作するでしょう
253(すなわち、上述のエラーメッセージが表示されます)。
254この場合、C<use> は 2 番目の項が I<数字のように見える> かどうかをチェックし、
255それを Replacement L<UNIVERSAL::VERSION>に渡すだけだという事実が
256関わってきます。
257しかし、このことは Perl 5.005_04 では正しくなく、そのために
258extended version をサポートする Perl のバージョンにおいてさえも、コード中では
259常に数値バージョンを使うことが B<強く推奨> されます。
260
261118=back
262119
263=head2 What IS a version
264
265(で、バージョンって何?)
266
267120=begin original
268121
269For the purposes of this module, a version "number" is a sequence of
122See L<VERSION OBJECT DETAILS> for further information.
270positive integer values separated by one or more decimal points and
271optionally a single underscore. This corresponds to what Perl itself
272uses for a version, as well as extending the "version as number" that
273is discussed in the various editions of the Camel book.
274123
275124=end original
276125
277このモジュールの用途のため、バージョン「番号」は、1以上の小数点と
126さらなる情報にいては L<VERSION OBJECT DETAILS> を参照してください。
278省略可能な
279一つのアンダースコアによって区切られる正の整数値とします。
280これは Perl 自身がバージョンを表すのに使用するものに対応し、また
281ラクダ本の各版で論じられた「数字としてのバージョン」を拡張します。
282127
283=begin original
128=head1 DECLARING VERSIONS
284129
285There are actually two distinct kinds of version objects:
130(バージョンの宣言)
286131
287=end original
288
289実際にはバージョンオブジェクトには 2 種類あります。
290
291=over 4
292
293=item * Numeric Versions
294
295(数値バージョン)
296
297132=begin original
298133
299Any initial parameter which "looks like a number", see L<Numeric
134If you have a module that uses a decimal $VERSION (floating point), and you
300Versions>. This also covers versions with a single decimal point and
135do not intend to ever change that, this module is not for you. There is
301a single embedded underscore, see L<Numeric Alpha Versions>, even though
136nothing that version.pm gains you over a simple $VERSION assignment:
302these must be quoted to preserve the underscore formatting.
303137
304138=end original
305139
306字のように見える」任意の初期引数 (L<Numeric Versions>参照)。
14010 進$VERSION (浮動小数点数)使うモジュールがあって、変更するつもりが
307れは小数点一つや途中にアンダースコア一つを持つバーョン含み
141ないなら、のモュールはあなたのためののではありせん。
308(L<Numeric Alpha Versions> を参照) が、アンダースコアの書式を
142単純な $VERSION 代入に対して version.pm から得られる利点はありません:
309保持するにはクォートされなければなりません。
310143
311=item * Extended Versions
144 our $VERSION = 1.02;
312145
313(拡張バージョン)
314
315146=begin original
316147
317Any initial parameter which contains more than one decimal point
148Since Perl v5.10.0 includes the version.pm comparison logic anyways,
318and an optional embedded underscore, see L<Extended Versions>. This
149you don't need to do anything at all.
319is what is commonly used in most open source software as the "external"
320version (the one used as part of the tag or tarfile name). The use
321of the exported L<qv()> function also produces this kind of version
322object.
323150
324151=end original
325152
3262 つ以上の小数点と任意の途中のアンダースコア一つ持つ任意初期引数
153Perl v5.10.0 からはどちらにしろ version.pm 比較ロジック含んでいるで、
327(L<Extended Versions> を参照)
154全く何もする必要はありません
328これはほとんどのオープンソースソフトウェアで「外部用」バージョン
329(タグや tar ファイル名の一部分として使われるもの) として一般的に
330使われているものです。
331エクスポートされた L<qv()> 関数を使用すると、この種のバージョン
332オブジェクトが生成されます。
333155
334=back
156=head2 How to convert a module from decimal to dotted-decimal
335157
336=begin original
158(10 進数からドット付き 10 進数へのモジュールの変換方法)
337159
338Both of these methods will produce similar version objects, in that
339the default stringification will yield the version L<Normal Form> only
340if required:
341
342=end original
343
344これらのメソッド両方が同様のバージョンオブジェクトを生成します;
345なぜなら、必要なときにのみデフォルトの文字列化はバージョンの
346L<Normal Form> を生み出すからです:
347
348 $v = version->new(1.002); # 1.002, but compares like 1.2.0
349 $v = version->new(1.002003); # 1.002003
350 $v2 = version->new("1.2.3"); # v1.2.3
351
352160=begin original
353161
354In specific, version numbers initialized as L<Numeric Versions> will
162If you have used a decimal $VERSION in the past and wish to switch to a
355stringify as they were originally created (i.e. the same string that was
163dotted-decimal $VERSION, then you need to make a one-time conversion to
356passed to C<new()>. Version numbers initialized as L<Extended Versions>
164the new format.
357will be stringified as L<Normal Form>.
358165
359166=end original
360167
361、L<Numeric Versions> とし初期化されたバージョン番号は
168過去10 進数 $VERSION を使っいて、ドット付き 10 進数 $VERSION に
362最初に作られた時のもの (つまり、C<new()> 渡されたのと同じ文字列) で
169替えたいなら一度だけ新しい形式変換する必要があります。
363文字列化します。
364L<Extended Versions> として初期化されたバージョン番号は
365L<Normal Form> として文字列化されます。
366170
367=head2 Numeric Versions
368
369(数値バージョン)
370
371171=begin original
372172
373These correspond to historical versions of Perl itself prior to 5.6.0,
173B<Important Note>: you must ensure that your new $VERSION is numerically
374as well as all other modules which follow the Camel rules for the
174greater than your current decimal $VERSION; this is not always obvious. First,
375$VERSION scalar. A numeric version is initialized with what looks like
175convert your old decimal version (e.g. 1.02) to a normalized dotted-decimal
376a floating point number. Leading zeros B<are> significant and trailing
176form:
377zeros are implied so that a minimum of three places is maintained
378between subversions. What this means is that any subversion (digits
379to the right of the decimal place) that contains less than three digits
380will have trailing zeros added to make up the difference, but only for
381purposes of comparison with other version objects. For example:
382177
383178=end original
384179
385これらは 5.6.0 より前Perl 自身の歴史上のバージョンや、$VERSION スカラ用の
180B<重要な注意>: 新しい $VERSION は数値的に現在10 進数 $VERSION より
386ラクダルールを踏襲する他のモジュール全てに対応しま
181大きくなければなりせん; これは常に自明というわけではありません
387バージョンは浮動小点のよう見えるもので初期化されます。
182最初に、古い 10 進数バージョン (例えば 1.02) をドット付き 10 進形式
388先頭の 0 は B<有効で> 末尾の 0 は暗黙に仮定されるので、3 点の
183変換します:
389最小値は下位バージョン間で保持されます。
390これが意味するのは、3 桁より少ない桁数の下位バージョン (小数点より
391右の数字) は全て末尾への0の追加によって補われますが、しかしそれは他の
392バージョンオブジェクトとの比較のためだけです。
393例えば:
394184
395 # Prints Equivalent to
185 $ perl -Mversion -e 'print version->parse("1.02")->normal'
396 $v = version->new( 1.2); # 1.2 v1.200.0
186 v1.20.0
397 $v = version->new( 1.02); # 1.02 v1.20.0
398 $v = version->new( 1.002); # 1.002 v1.2.0
399 $v = version->new( 1.0023); # 1.0023 v1.2.300
400 $v = version->new( 1.00203); # 1.00203 v1.2.30
401 $v = version->new( 1.002003); # 1.002003 v1.2.3
402187
403188=begin original
404189
405All of the preceding examples are true whether or not the input value is
190Then increment any of the dotted-decimal components (v1.20.1 or v1.21.0).
406quoted. The important feature is that the input value contains only a
407single decimal. See also L<Alpha Versions> for how to handle
408191
409192=end original
410193
411入力値がクォートさているに関わず、先行例は全て真となります
194れからドット付き 10 進数の要素のどれかをインクリメントします
412重要な特徴として、入力値が一つの小数点を持つことがあり
195(v1.20.1 たは v1.21.0)
413扱う方法は L<Alpha Versions> も参照してください。
414196
415=begin original
197=head2 How to C<declare()> a dotted-decimal version
416198
417IMPORTANT NOTE: As shown above, if your numeric version contains more
199(ドット付き 10 進数バージョンを C<declare()> する方法)
418than 3 significant digits after the decimal place, it will be split on
419each multiple of 3, so 1.0003 is equivalent to v1.0.300, due to the need
420to remain compatible with Perl's own 5.005_03 == 5.5.30 interpretation.
421Any trailing zeros are ignored for mathematical comparison purposes.
422200
423=end original
201 use version 0.77; our $VERSION = version->declare("v1.2.3");
424202
425重要な注意:上述で示されているように、数値バージョンが小数点の後に 3 つを
426超える有効桁数を含む場合、3 の各倍数で区切られるので 1.0003 は v1.0.300 と
427等しくなります。
428これは Perl 自身の 5.005_03 == 5.5.30 という解釈との互換性を
429維持する必要があるためです。
430末尾の 0 は数学的な比較用に全て無視されます。
431
432=head2 Extended Versions
433
434(拡張バージョン)
435
436203=begin original
437204
438These are the newest form of versions, and correspond to Perl's own
205The C<declare()> method always creates dotted-decimal version objects. When
439version style beginning with 5.6.0. Starting with Perl 5.10.0,
206used in a module, you B<must> put it on the same line as "use version" to
440and most likely Perl 6, this is likely to be the preferred form. This
207ensure that $VERSION is read correctly by PAUSE and installer tools. You
441method normally requires that the input parameter be quoted, although
208should also add 'version' to the 'configure_requires' section of your
442Perl's after 5.8.1 can use v-strings as a special form of quoting, but
209module metadata file. See instructions in L<ExtUtils::MakeMaker> or
443this is highly discouraged.
210L<Module::Build> for details.
444211
445212=end original
446213
447これら最も新しい形式のバージョンで、5.6.0 から始まる Perl 自身の
214C<declare()> メソッド常にドット付き 10 進数バージョンオブジェクトを
448バージョン形式に対応します。
215作成します。
449Perl 5.10.0 からは、またほぼ確実に Perl 6 でも、これ
216モジュールで使うときは、PAUSE やインストーラツールによって $VERSION
450まれる形式になりそです。
217正しく読み込まれるに "use version" と同じ行に
451このメソッドは通常入力引数がクォートさている必要があ
218B<書かなけばなません>。
452また 5.8.1 以降Perl では v-文字列クォートの特別形式として
219また、モジュールメタデータファイル'configure_requires' 節に 'version'
453使用することがでますが、これは強く非推奨です。
220追加するきです。
221詳細については L<ExtUtils::MakeMaker> または L<Module::Build> の説明を
222参照してください。
454223
455224=begin original
456225
457Unlike L<Numeric Versions>, Extended Versions have more than
226B<Important Note>: Even if you pass in what looks like a decimal number
458a single decimal point, e.g.:
227("1.2"), a dotted-decimal will be created ("v1.200.0"). To avoid confusion
228or unintentional errors on older Perls, follow these guidelines:
459229
460230=end original
461231
462L<Numeric Versions> と違って、拡張バージョンは 2 つ以上の小
232B<重要な注意>: 例え 10 のように見えるもの ("1.2") 渡しても、ドット付き
463持ちます。
23310 進数 ("v1.200.0") が作成されます。
464例えば:
234古い Perl での混乱や意図しないエラーを防ぐために、以下のガイドラインに
235従ってください:
465236
466 # Prints
237=over 2
467 $v = version->new( "v1.200"); # v1.200.0
468 $v = version->new("v1.20.0"); # v1.20.0
469 $v = qv("v1.2.3"); # v1.2.3
470 $v = qv("1.2.3"); # v1.2.3
471 $v = qv("1.20"); # v1.20.0
472238
473=begin original
239=item *
474240
475In general, Extended Versions permit the greatest amount of freedom
476to specify a version, whereas Numeric Versions enforce a certain
477uniformity. See also L<New Operator> for an additional method of
478initializing version objects.
479
480=end original
481
482一般的に、拡張バージョンは最も高い自由度でバージョンを指定でき、その
483一方で数値バージョンは一定の統一性を強制します。
484バージョンオブジェクトのもう一つの補助的な初期化メソッドについては
485L<New Operator> も参照してください。
486
487241=begin original
488242
489Just like L<Numeric Versions>, Extended Versions can be used as
243Always use a dotted-decimal with (at least) three components
490L<Alpha Versions>.
491244
492245=end original
493246
494L<Numeric Versions> と全同様に、拡張バージョンは L<Alpha Versions> として
247常に (少なとも) 3 要素のあるドット付き 10 進数を使う
495使用することができます。
496248
497=head2 Numeric Alpha Versions
249=item *
498250
499(数値αバージョン)
500
501251=begin original
502252
503The one time that a numeric version must be quoted is when a alpha form is
253Always use a leading-v
504used with an otherwise numeric version (i.e. a single decimal point). This
505is commonly used for CPAN releases, where CPAN or CPANPLUS will ignore alpha
506versions for automatic updating purposes. Since some developers have used
507only two significant decimal places for their non-alpha releases, the
508version object will automatically take that into account if the initializer
509is quoted. For example Module::Example was released to CPAN with the
510following sequence of $VERSION's:
511254
512255=end original
513256
514かつて数値バージョンが必ずクォートされていなければならなかったは、
257常に先頭 v を使う
515アルファ形式が他の数値バージョン (すなわち小数点が一つ) と一緒に
516使われていたときです。
517これはよく CPAN リリースに使われており、そこで CPAN や
518CPANPLUS は自動アップデートのためにアルファバージョンを無視します。
519非アルファリリースに小数の有効桁数を2としていた開発者がいたため、
520バージョンオブジェクトは初期化子がクォートされていれば自動的に
521それを考慮します。
522例えば、Module::Example が以下の $VERSION 系列で CPAN に
523リリースされたとします:
524258
525 # $VERSION Stringified
259=item *
526 0.01 0.01
527 0.02 0.02
528 0.02_01 0.02_01
529 0.02_02 0.02_02
530 0.03 0.03
531 etc.
532260
533261=begin original
534262
535The stringified form of numeric versions will always be the same string
263Always quote the version
536that was used to initialize the version object.
537264
538265=end original
539266
540数値バージョンの文字列化形式は、常にバージョンオブジェクトの初期化に
267常にバージョンォーする
541使われるのと同じ文字列です。
542268
543=head2 Object Methods
544
545(オブジェクトメソッド)
546
547=begin original
548
549Overloading has been used with version objects to provide a natural
550interface for their use. All mathematical operations are forbidden,
551since they don't make any sense for base version objects. Consequently,
552there is no overloaded numification available. If you want to use a
553version object in a numeric context for some reason, see the L<numify>
554object method.
555
556=end original
557
558バージョンオブジェクトの利用にとって自然なインタフェースを提供するために、
559オーバーロードが使われてきました。
560数学的な演算は全て、ベースのバージョンオブジェクトに対して意味を
561成さないので、禁止されています。
562その結果、オーバーロードされた数値化は存在せず利用できません。
563もし何らかの理由でバージョンオブジェクトを数値コンテキストで使用したい
564場合は、オブジェクトメソッドの L<numify> を参照してください。
565
566=over 4
567
568=item * New Operator
569
570(new 演算子)
571
572=begin original
573
574Like all OO interfaces, the new() operator is used to initialize
575version objects. One way to increment versions when programming is to
576use the CVS variable $Revision, which is automatically incremented by
577CVS every time the file is committed to the repository.
578
579=end original
580
581全ての OO インタフェースと同様に、new() 演算子はバージョンオブジェクトを
582初期化するために使われます。
583プログラミング時にバージョンをインクリメントするための方法の一つは
584CVS 変数の $Revision を使うことです。
585$Revision はファイルがリポジトリにコミットされた際に毎回 CVS によって
586自動的にインクリメントされます。
587
588=begin original
589
590In order to facilitate this feature, the following
591code can be employed:
592
593=end original
594
595この機能を容易に行うために、以下のコードが利用できます:
596
597 $VERSION = version->new(qw$Revision: 2.7 $);
598
599=begin original
600
601and the version object will be created as if the following code
602were used:
603
604=end original
605
606これにより、以下のコードが使われたかのようにバージョンオブジェクトが
607作成されます:
608
609 $VERSION = version->new("v2.7");
610
611=begin original
612
613In other words, the version will be automatically parsed out of the
614string, and it will be quoted to preserve the meaning CVS normally
615carries for versions. The CVS $Revision$ increments differently from
616numeric versions (i.e. 1.10 follows 1.9), so it must be handled as if
617it were a L<Extended Version>.
618
619=end original
620
621言い換えると、構文解析により文字列からバージョンが自動的に取り出され、
622CVS が通常バージョンで伝える意味を保つためにそれがクォートされます。
623CVS の $Revision$ は数値バージョンとは異なった方法でインクリメントされる
624(すなわち 1.9 の後に 1.10 が続く) ので、それが L<Extended Versions> で
625あるかのように扱わなければなりません。
626
627=begin original
628
629A new version object can be created as a copy of an existing version
630object, either as a class method:
631
632=end original
633
634新しいバージョンオブジェクトは既存のバージョンオブジェクトのコピーとして
635作成可能で、クラスメソッドとして作成する:
636
637 $v1 = version->new(12.3);
638 $v2 = version->new($v1);
639
640=begin original
641
642or as an object method:
643
644=end original
645
646ことも、あるいはオブジェクトメソッドとして作成する:
647
648 $v1 = version->new(12.3);
649 $v2 = $v1->new(12.3);
650
651=begin original
652
653and in each case, $v1 and $v2 will be identical. NOTE: if you create
654a new object using an existing object like this:
655
656=end original
657
658こともでき、それぞれの例において、$v1 と $v2 は同一です。
659注意: もし新しいオブジェクトを次のように既存のオブジェクトを使って
660作成する場合:
661
662 $v2 = $v1->new();
663
664=begin original
665
666the new object B<will not> be a clone of the existing object. In the
667example case, $v2 will be an empty object of the same type as $v1.
668
669=end original
670
671新しいオブジェクトは既存のオブジェクトのクローンには B<なりません>。
672この例では、$v2 は $v1 と同じ種類の空のオブジェクトになります。
673
674269=back
675270
676=over 4
677
678=item * qv()
679
680271=begin original
681272
682An alternate way to create a new version object is through the exported
273If you really insist on using version.pm with an ordinary decimal version,
683qv() sub. This is not strictly like other q? operators (like qq, qw),
274use C<parse()> instead of declare. See the L<PARSING AND COMPARING VERSIONS>
684in that the only delimiters supported are parentheses (or spaces). It is
275for details.
685the best way to initialize a short version without triggering the floating
686point interpretation. For example:
687276
688277=end original
689278
690新しいバージョンオブジェクトを作成する別の方法に、エクスポートされた
279本当に version.pm を普通の 10 進数バージョンで使うことこだわるなら
691qv() 関数を使う方法があります
280declare の代わりに C<parse()> を使ってください
692これ、利用可能なデリミタが丸カッコ (またはスペース) のみであるとう点で、
281詳しくL<PARSING AND COMPARING VERSIONS> を参照してくださ
693厳密には他の q? 演算子 (qq, qw など) とは似ていません。
694これは、小数点解釈を引き起こすことなしに短いバージョンを初期化するための
695最良の方法です。
696例えば:
697282
698 $v1 = qv(1.2); # 1.2.0
699 $v2 = qv("1.2"); # also 1.2.0
700
701283=begin original
702284
703As you can see, either a bare number or a quoted string can usually
285See also L<VERSION OBJECT DETAILS> for more on version number conversion,
704be used interchangably, except in the case of a trailing zero, which
286quoting, calculated version numbers and declaring developer or "alpha" version
705must be quoted to be converted properly. For this reason, it is strongly
287numbers.
706recommended that all initializers to qv() be quoted strings instead of
707bare numbers.
708288
709289=end original
710290
711ご覧の通り裸の数値またはクォートされた文字列は通常交換して
291バージョン番号変換、クォート、バージョン番号の計算、開発者バージョンや
712使用できます。
292「α」バージョン番号の宣言に関してさらなる情報は L<VERSION OBJECT DETAILS> も
713ただ、末尾に 0 があるケースは、正し変換するためにクォートれる必要が
293参照い。
714あるので例外です。
715この理由のため、qv() への全ての初期化子は裸の数値のかわりに
716クォートされた文字列とすることが強く推奨されます。
717294
718=begin original
295=head1 PARSING AND COMPARING VERSIONS
719296
720To prevent the C<qv()> function from being exported to the caller's namespace,
297(バージョンのパースと比較)
721either use version with a null parameter:
722298
723=end original
724
725C<qv()> 関数が呼び出し側の名前空間にエクスポートされるのを防ぐために、空の
726引数で use version を呼び出すか:
727
728 use version ();
729
730299=begin original
731300
732or just require version, like this:
301If you need to compare version numbers, but can't be sure whether they are
302expressed as numbers, strings, v-strings or version objects, then you can
303use version.pm to parse them all into objects for comparison.
733304
734305=end original
735306
736あるいは単に require version を行う:
307バージョン番号を比較する必要があるけれども、バージョン番号が数値なの
308文字列なのかv-文字列なのかバージョンオブジェクトなのか分からない場合、
309これら全てを比較のためにパースするために version.pm を使えます。
737310
738 require version;
311=head2 How to C<parse()> a version
739312
740=begin original
313(バージョンの C<parse()> の方法)
741314
742Both methods will prevent the import() method from firing and exporting the
743C<qv()> sub. This is true of subclasses of version as well, see
744L<SUBCLASSING> for details.
745
746=end original
747
748のいずれかを行ってください。
749両方のメソッドとも import() メソッドが起動して C<qv()> サブルーチンを
750エクスポートするのを防ぎます。
751このことは version のサブクラスでも同じように成り立ちます。
752詳しくは L<SUBCLASSING> を参照してください。
753
754=back
755
756315=begin original
757316
758For the subsequent examples, the following three objects will be used:
317The C<parse()> method takes in anything that might be a version and returns
318a corresponding version object, doing any necessary conversion along the way.
759319
760320=end original
761321
762以降以下の 3 つのオブジェクトが使われます:
322C<parse()> メソッドはバージョンになりそうなももを取って必要な
323変換を行って、対応するバージョンオブジェクトを返します。
763324
764 $ver = version->new("1.2.3.4"); # see "Quoting" below
325=over 2
765 $alpha = version->new("1.2.3_4"); # see "Alpha versions" below
766 $nver = version->new(1.002); # see "Numeric Versions" above
767326
768=over 4
327=item *
769328
770=item * Normal Form
771
772(正規形式)
773
774329=begin original
775330
776For any version object which is initialized with multiple decimal
331Dotted-decimal: bare v-strings (v1.2.3) and strings with more than one
777places (either quoted or if possible v-string), or initialized using
332decimal point and a leading 'v' ("v1.2.3"); NOTE you can technically use a
778the L<qv()> operator, the stringified representation is returned in
333v-string or strings with a leading-v and only one decimal point (v1.2 or
779a normalized or reduced form (no extraneous zeros), and with a leading 'v':
334"v1.2"), but you will confuse both yourself and others.
780335
781336=end original
782337
783の小数点 (クォートされたもか可能であればv-文字列) を用いて、
338ドット付き 10 進: のv-文字列 (v1.2.3) と先頭の 'v' と複数の小数点がある
784もしくは L<qv()> 演算子を用いて初期化されたバージョンオブジェクトのため
339文字列 ("v1.2.3"); 注意: 技術的は小数点が一つしかないv-文字列や文字列
785文字列化された表現形式が正規化もしくは縮小された形式 (余分なゼロを削除)
340(v1.2 や "v1.2") も使えますが自分自身も他人も混乱させます。
786先頭に 'v' が付いて返されます:
787341
788 print $ver->normal; # prints as v1.2.3.4
342=item *
789 print $ver->stringify; # ditto
790 print $ver; # ditto
791 print $nver->normal; # prints as v1.2.0
792 print $nver->stringify; # prints as 1.002, see "Stringification"
793343
794344=begin original
795345
796In order to preserve the meaning of the processed version, the
346Decimal: regular decimal numbers (literal or in a string)
797normalized representation will always contain at least three sub terms.
798In other words, the following is guaranteed to always be true:
799347
800348=end original
801349
802処理されバージョンの意味を保つために、正規化された表現形式必ず最低
35010 進数: (リテラルまたは文字列の中の) 普通の 10 進数
8033 つの下位項を持たなければなりません。
804言い換えると、以下のコードは常に真となることが保証されます:
805351
806 my $newver = version->new($ver->stringify);
807 if ($newver eq $ver ) # always true
808 {...}
809
810352=back
811353
812=over 4
813
814=item * Numification
815
816(数値化)
817
818354=begin original
819355
820Although all mathematical operations on version objects are forbidden
356Some examples:
821by default, it is possible to retrieve a number which corresponds
822to the version object through the use of the $obj->numify
823method. For formatting purposes, when displaying a number which
824corresponds a version object, all sub versions are assumed to have
825three decimal places. So for example:
826357
827358=end original
828359
829バージョンオブジェクトに対する数学的な演算はデフォルトでは全て
360いくつかの例:
830禁止されていますが、$obj->numify メソッドを使うことでそのバージョン
831オブジェクトに対応した数値を取り出すことが可能です。
832フォーマッティングのために、バージョンオブジェクトに対応する数値を
833表示する際には、下位バージョンは全て 3 桁あると仮定されます。
834従って、例を挙げると以下のようになります:
835361
836 print $ver->numify; # prints 1.002003004
362 $variable version->parse($variable)
837 print $nver->numify; # prints 1.002
363 --------- -------------------------
364 1.23 v1.230.0
365 "1.23" v1.230.0
366 v1.23 v1.23.0
367 "v1.23" v1.23.0
368 "1.2.3" v1.2.3
369 "v1.2.3" v1.2.3
838370
839371=begin original
840372
841Unlike the stringification operator, there is never any need to append
373See L<VERSION OBJECT DETAILS> for more on version number conversion.
842trailing zeros to preserve the correct version value.
843374
844375=end original
845376
846文字列化演算子と違って、正しいバージョン値を保持するため末尾のゼロ
377さらなるバージョン番号変換ついては L<VERSION OBJECT DETAILS>
847追加する必要は全ありません
378参照してださい
848379
849=back
380=head2 How to compare version objects
850381
851=over 4
382(バージョンオブジェクトの比較の方法)
852383
853=item * Stringification
854
855(文字列化)
856
857384=begin original
858385
859The default stringification for version objects returns exactly the same
386Version objects overload the C<cmp> and C<< E<lt>=E<gt> >> operators. Perl
860string as was used to create it, whether you used C<new()> or C<qv()>,
387automatically generates all of the other comparison operators based on those
861with one exception. The sole exception is if the object was created using
388two so all the normal logical comparisons will work.
862C<qv()> and the initializer did not have two decimal places or a leading
863'v' (both optional), then the stringified form will have a leading 'v'
864prepended, in order to support round-trip processing.
865389
866390=end original
867391
868バージョンオブジェクトの文字列化のデフォルト
392バージョンオブジェクトは C<cmp> と C<< E<lt>=E<gt> >> の演算子を
869C<new()> によるか C<qv()> によるかに関わらず、
393オーバーロードします。
870オブジェクトしたのと全く同じ文字列となりまひとつ例外が
394Perl はこの二つから自動的にその他の比較演算子成するので通常論理比較は
871あります。
395動作します。
872唯一の例外は、オブジェクトが C<qv()> を使って作成され、
873初期化子が 2 つの十進数がなかったり、先頭の 'v' がない場合
874(これらは両方ともオプションです)、循環処理に対応するために、
875文字列化形式は先頭に 'v' がつきます。
876396
877=begin original
397 if ( version->parse($v1) == version->parse($v2) ) {
398 # do stuff
399 }
878400
879For example:
880
881=end original
882
883例えば:
884
885 Initialized as Stringifies to
886 ============== ==============
887 version->new("1.2") 1.2
888 version->new("v1.2") v1.2
889 qv("1.2.3") 1.2.3
890 qv("v1.3.5") v1.3.5
891 qv("1.2") v1.2 ### exceptional case
892
893401=begin original
894402
895See also L<UNIVERSAL::VERSION>, as this also returns the stringified form
403If a version object is compared against a non-version object, the non-object
896when used as a class method.
404term will be converted to a version object using C<parse()>. This may give
405surprising results:
897406
898407=end original
899408
900L<UNIVERSAL::VERSION> 参照してくだい; こも、クラスメソッドして
409バージョンオブジェクトがバージョンオブジェクトでないのと比較され
901使われたときに文字列化形式返します。
410非オブジェクト側 C<parse()> 使ってバージョンオブジェクトに変換されます。
411これにより驚くべき結果になるかもしれません:
902412
903=back
413 $v1 = version->parse("v0.95.0");
414 $bool = $v1 < 0.96; # FALSE since 0.96 is v0.960.0
904415
905=over 4
906
907=item * Comparison operators
908
909(比較演算子)
910
911416=begin original
912417
913Both C<cmp> and C<E<lt>=E<gt>> operators perform the same comparison between
418Always comparing to a version object will help avoid surprises:
914terms (upgrading to a version object automatically). Perl automatically
915generates all of the other comparison operators based on those two.
916In addition to the obvious equalities listed below, appending a single
917trailing 0 term does not change the value of a version for comparison
918purposes. In other words "v1.2" and "1.2.0" will compare as identical.
919419
920420=end original
921421
922C<cmp> と C<E<lt>=E<gt>> は両方とも同じ比較を項間でます (自動的に
422常にバージョンオブジェクトの比較を行うことは驚くことを避ける助けになります:
923バージョンオブジェクトにアップグレードします)。
924それら 2 つに基づいて、Perl は他の比較演算子を全て自動的に生成します。
925以下に挙げられている明らかな等値性に加えて、末尾に 0 の項を一つ追加しても
926比較用のバージョン値は変化しません。
927言い換えると、"v1.2" と"1.2.0" の比較は同一と見なされます。
928423
929=begin original
424 $bool = $v1 < version->parse("v0.96.0"); # TRUE
930425
931For example, the following relations hold:
426=head1 VERSION OBJECT DETAILS
932427
933=end original
428(バージョンオブジェクトの詳細)
934429
935例えば、以下の関係が維持されます:
430=head2 Equivalence between Decimal and Dotted-Decimal Versions
936431
937 As Number As String Truth Value
432(10 進数バージョンとドット付き 10 進数バージョンの等価性)
938 ------------- ---------------- -----------
939 $ver > 1.0 $ver gt "1.0" true
940 $ver < 2.5 $ver lt true
941 $ver != 1.3 $ver ne "1.3" true
942 $ver == 1.2 $ver eq "1.2" false
943 $ver == 1.2.3.4 $ver eq "1.2.3.4" see discussion below
944433
945434=begin original
946435
947It is probably best to chose either the numeric notation or the string
436When Perl 5.6.0 was released, the decision was made to provide a
948notation and stick with it, to reduce confusion. Perl6 version objects
437transformation between the old-style decimal versions and new-style
949B<may> only support numeric comparisons. See also L<Quoting>.
438dotted-decimal versions:
950439
951440=end original
952441
953数値記法か文字列記法のどちらかを選んでそを使い続けるこ混乱を
442Perl 5.6.0 がリリースさ古い形式の 10 進数バージョンと新しい形式の
954避けるためにはおそらくベスでしょ
443ドッ付き 10 進数バージョンの変換を提供するとい決定がなされました:
955Perl6 のバージョンオブジェクトは数値比較のみを
956サポートする B<かもしれません>。
957L<Quoting> も参照してください。
958444
959=begin original
445 5.6.0 == 5.006000
446 5.005_04 == 5.5.40
960447
961WARNING: Comparing version with unequal numbers of decimal points (whether
962explicitly or implicitly initialized), may yield unexpected results at
963first glance. For example, the following inequalities hold:
964
965=end original
966
967警告:(初期化が明示的か暗黙的かに関わらず) 小数点の数が異なるバージョンの
968比較は一見すると期待しない結果を生み出すかもしれません。
969例えば、以下の非等値性が成り立ちます:
970
971 version->new(0.96) > version->new(0.95); # 0.960.0 > 0.950.0
972 version->new("0.96.1") < version->new(0.95); # 0.096.1 < 0.950.0
973
974448=begin original
975449
976For this reason, it is best to use either exclusively L<Numeric Versions> or
450The floating point number is taken and split first on the single decimal
977L<Extended Versions> with multiple decimal points.
451place, then each group of three digits to the right of the decimal makes up
452the next digit, and so on until the number of significant digits is exhausted,
453B<plus> enough trailing zeros to reach the next multiple of three.
978454
979455=end original
980456
981理由ため、L<Numeric Versions> か L<Extended Versions> どちらかを
457浮動小数点数を取って、まず小数点で分割し、それから小数点右側3
982排他的、かつ複数点を付け使うことベストす。
458グループ毎の数値にし、有効数字なくなるまこれを繰り返し、B<さらに>
4593 の倍数になるように末尾に 0 を追加します。
983460
984=back
985
986=over 4
987
988=item * Logical Operators
989
990461=begin original
991462
992If you need to test whether a version object
463This was the method that version.pm adopted as well. Some examples may be
993has been initialized, you can simply test it directly:
464helpful:
994465
995466=end original
996467
997もしバージョンオブジェクトが初期化されているかどうかを確かめたければ、
468は version.pm が採用している方法でもあります。
998簡単直接テストきます:
469いくつかの例が助けなるしょう:
999470
1000 $vobj = version->new($something);
471 equivalent
1001 if ( $vobj ) # true only if $something was non-blank
472 decimal zero-padded dotted-decimal
473 ------- ----------- --------------
474 1.2 1.200 v1.200.0
475 1.02 1.020 v1.20.0
476 1.002 1.002 v1.2.0
477 1.0023 1.002300 v1.2.300
478 1.00203 1.002030 v1.2.30
479 1.002003 1.002003 v1.2.3
1002480
1003=begin original
481=head2 Quoting rules
1004482
1005You can also test whether a version object is an L<Alpha version>, for
483(クォート規則)
1006example to prevent the use of some feature not present in the main
1007release:
1008484
1009=end original
1010
1011また、例えばメインリリースでは提供されない機能の使用を防ぐといった
1012目的のために、バージョンオブジェクトが L<Alpha Versions> であるかどうかを
1013確かめるには以下のようにします:
1014
1015 $vobj = version->new("1.2_3"); # MUST QUOTE
1016 ...later...
1017 if ( $vobj->is_alpha ) # True
1018
1019=back
1020
1021=head2 Quoting
1022
1023(クォート)
1024
1025485=begin original
1026486
1027487Because of the nature of the Perl parsing and tokenizing routines,
1028488certain initialization values B<must> be quoted in order to correctly
1029parse as the intended version, especially when using the L<qv()> operator.
489parse as the intended version, especially when using the L<declare> or
1030In all cases, a floating point number passed to version->new() will be
490L<qv> methods. While you do not have to quote decimal numbers when
1031identically converted whether or not the value itself is quoted. This is
491creating version objects, it is always safe to quote B<all> initial values
1032not true for L<qv()>, however, when trailing zeros would be stripped on
492when using version.pm methods, as this will ensure that what you type is
1033an unquoted input, which would result in a very different version object.
493what is used.
1034494
1035495=end original
1036496
1037Perl パースとトークン化を行うプログラム仕組みのため、意図し
497Perl パースとトークン化ルーチン性質により一部の初期化値は意図している
1038バージョン正しくパースするために、特に L<qv()> 演算子を使用する際には、
498バージョンとして正しくパースするためにクォート B<されなければなりません>;
1039定の初期値は B<必ず> クォートしなければなりません
499 L<declare> や L<qv> メソッドではです
1040全てのケおいて、version->new() に渡される浮動小点数の値は、その値
500ジョンオブジェクトを作成するとき10 進をクォートする必要ない一方、
1041クォートされていようなかろうと同一変換されます。
501version.pm メソッドを使うときに B<全ての> 初期値をクォートするこは常
1042しかし、L<qv()> は、クォートされていない入力で末尾ゼロ
502安全す; 入力したものがどのように使われるかを確実にするからです。
1043抜け落ちてしまう場合にはそのようにならず、全く異なる
1044バージョンオブジェクトが結果として返されます。
1045503
1046504=begin original
1047505
1048In addition, in order to be compatible with earlier Perl version styles,
506Additionally, if you quote your initializer, then the quoted value that goes
1049any use of versions of the form 5.006001 will be translated as v5.6.1.
507B<in> will be be exactly what comes B<out> when your $VERSION is printed
1050In other words, a version with a single decimal point will be parsed as
508(stringified). If you do not quote your value, Perl's normal numeric handling
1051implicitly having three digits between subversions, but only for internal
509comes into play and you may not get back what you were expecting.
1052comparison purposes.
1053510
1054511=end original
1055512
1056加えて以前の Perl のバージョンスタイルと互換性保つために5.006001
513さらに初期化子クォートする場合B<入力>してクォートされた値は
1057いう形式のバージョンを使用すると全て v5.6.1 のように変換されます。
514$VERSION が表示される(文字列化される)ときに正確に同じものが
1058言い換えると、小数点が 1 つのバージョンは、下位バージョン間には 3 桁の
515B<出力> されます。
1059暗黙的に存在するようにパースさますが目的は内部比較のみです。
516値をクォートしていない場合、Perl の通常の値の処理行われ、想定したも
517戻らないかもしれません。
1060518
1061519=begin original
1062520
1063The complicating factor is that in bare numbers (i.e. unquoted), the
1064underscore is a legal numeric character and is automatically stripped
1065by the Perl tokenizer before the version code is called. However, if
1066a number containing one or more decimals and an underscore is quoted, i.e.
1067not bare, that is considered a L<Alpha Version> and the underscore is
1068significant.
1069
1070=end original
1071
1072ややこしくしている要因は、裸の数値 (すなわちクォートされていないもの) では
1073アンダースコアは正当な数値用の文字であって、バージョンコードが
1074呼び出される前に Perl のトークナイザによって自動的に剥ぎ取られることです。
1075しかしながら、もし数値が 1 つ以上の小数を含んでいてアンダースコアが
1076クォートされている場合、すなわち裸の数値ではない場合、
1077L<Alpha Version> であると見なされてアンダースコアが有効になります。
1078
1079=begin original
1080
1081521If you use a mathematic formula that resolves to a floating point number,
1082522you are dependent on Perl's conversion routines to yield the version you
1083523expect. You are pretty safe by dividing by a power of 10, for example,
1084524but other operations are not likely to be what you intend. For example:
1085525
1086526=end original
1087527
1088もし浮動小数が求まる数使った場合、期待するバージョンみ出せるか
528浮動小数点数になる数値演算った場合、想定したバージョン成されるか
1089どうかは Perl の変換ルーチンに依存することになります。
529Perl の変換ルーチンに依存ます。
1090例えば 10 の累乗で割ることは非常に安全ですが、他の演算はおそらく期待する
530例えば10 の累乗で割ることはかなり安全ですが、その他の演算はおそらく
1091にはならないでしょう
531意図した通りにはなりません
1092532例えば:
1093533
1094534 $VERSION = version->new((qw$Revision: 1.4)[1]/10);
1095535 print $VERSION; # yields 0.14
1096536 $V2 = version->new(100/9); # Integer overflow in decimal number
1097537 print $V2; # yields something like 11.111.111.100
1098538
1099539=begin original
1100540
1101Perl 5.8.1 and beyond will be able to automatically quote v-strings but
541Perl 5.8.1 and beyond are able to automatically quote v-strings but
1102542that is not possible in earlier versions of Perl. In other words:
1103543
1104544=end original
1105545
1106Perl 5.8.1 以降はv-文字列を自動的にクォートできますが、それ以前の
546Perl 5.8.1 以降は自動的にv-文字列をクォートできますが、それ以前の Perl では
1107バージョンの Perl は不可能です
547きません
1108言い換えると:
548言い換えると:
1109549
1110550 $version = version->new("v2.5.4"); # legal in all versions of Perl
1111551 $newvers = version->new(v2.5.4); # legal only in Perl >= 5.8.1
1112552
1113553=head2 What about v-strings?
1114554
1115555(v-文字列はどう?)
1116556
1117557=begin original
1118558
1119Beginning with Perl 5.6.0, an alternate method to code arbitrary strings
1120of bytes was introduced, called v-strings. They were intended to be an
1121easy way to enter, for example, Unicode strings (which contain two bytes
1122per character). Some programs have used them to encode printer control
1123characters (e.g. CRLF). They were also intended to be used for $VERSION,
1124but their use as such has been problematic from the start.
1125
1126=end original
1127
1128Perl 5.6.0 以降では、任意のバイト列をコーディングする代替方法が導入され、
1129v-文字列と呼ばれています。
1130v-文字列は、例えば (1 文字あたり 2 バイトを使う)
1131Unicode 文字列のようなものを入力するのが簡単なようになっています。
1132プリンタ制御文字 (すなわち CRLF) をエンコードするためにv-文字列を
1133使っているプログラムもあります。
1134v-文字列は $VERSION のために使われるようにも意図されていましたが、
1135そのような使用は初めから問題をはらんでいました。
1136
1137=begin original
1138
1139559There are two ways to enter v-strings: a bare number with two or more
1140560decimal points, or a bare number with one or more decimal points and a
1141561leading 'v' character (also bare). For example:
1142562
1143563=end original
1144564
1145565v-文字列を入力する方法は 2 つあります。
11465662 つ以上の小数点を持つ裸の数値か、先頭に裸の文字 'v' があって
11475671 つ以上の小数点を持つ裸の数値です。
1148568例えば:
1149569
1150570 $vs1 = 1.2.3; # encoded as \1\2\3
1151571 $vs2 = v1.2; # encoded as \1\2
1152572
1153573=begin original
1154574
1155575However, the use of bare v-strings to initialize version objects is
1156B<strongly> discouraged in all circumstances (especially the leading
576B<strongly> discouraged in all circumstances. Also, bare
1157'v' style), since the meaning will change depending on which Perl you
577v-strings are not completely supported in any version of Perl prior to
1158are running. It is better to directly use L<"Extended Versions"> to
5785.8.1.
1159ensure the proper interpretation.
1160579
1161580=end original
1162581
1163582しかしながら、バージョンオブジェクトを初期化するために裸のv-文字列を
1164使用することは、実行しいる Perl が何かに依存して意味が変わるの
583使用することは、どのような状況であっ B<強く> 非推奨す。
1165ような状況であっても B<強く> 非推奨です (特に先頭に'v' が付く
584また、裸v-文字列は 5.8.1 より前のバージョンの Perl は完全には
1166スタイルは)
585対応していません
1167L<"Extended Versions"> を直接使って適切な解釈を確実にすることが
1168より良いでしょう。
1169586
1170587=begin original
1171588
1172589If you insist on using bare v-strings with Perl > 5.6.0, be aware of the
1173590following limitations:
1174591
1175592=end original
1176593
1177594もし Perl > 5.6.0 で裸のv-文字列を使うことにこだわる場合、以下の制限に
1178595注意してください。
1179596
1180597=begin original
1181598
11825991) For Perl releases 5.6.0 through 5.8.0, the v-string code merely guesses,
1183600based on some characteristics of v-strings. You B<must> use a three part
1184601version, e.g. 1.2.3 or v1.2.3 in order for this heuristic to be successful.
1185602
1186603=end original
1187604
1188605Perl のリリース 5.6.0 から 5.8.0 において、v-文字列コードはv-文字列の
1189606いくつかの特徴に基づいて単に推測を行うのみです。
1190607このヒューリスティクスが成功するためには、必ず 3 つの部分
1191608(例えば 1.2.3 や v1.2.3) のバージョンを使わなければ B<なりません>。
1192609
1193610=begin original
1194611
11956122) For Perl releases 5.8.1 and later, v-strings have changed in the Perl
1196613core to be magical, which means that the version.pm code can automatically
1197614determine whether the v-string encoding was used.
1198615
1199616=end original
1200617
1201618Perl のリリース 5.8.1 以降では、v-文字列は Perl コアでマジカルになるように
1202619変更されました。
1203620つまり、version.pm コードがv-文字列エンコーディングが使われたかどうかを
1204621自動的に判断できるようになったということです。
1205622
1206623=begin original
1207624
12086253) In all cases, a version created using v-strings will have a stringified
1209626form that has a leading 'v' character, for the simple reason that sometimes
1210627it is impossible to tell whether one was present initially.
1211628
1212629=end original
1213630
12146313) 全ての場合で、v-文字列を使って作成されたバージョンは
1215632文字列化形式にしたときに先頭に 'v' の文字がつきます;
1216633ときどき、これが先頭に付いていたかを確認することが不可能であるという
1217634単純な理由によります。
1218635
1219=head2 Types of Versions Objects
636=head2 Alpha versions
1220637
1221(バージョンオブジェクトの種類)
1222
1223=begin original
1224
1225There are two types of Version Objects:
1226
1227=end original
1228
12292 種類のバージョンオブジェクトが存在します。
1230
1231=over 4
1232
1233=item * Ordinary versions
1234
1235(通常のバージョン)
1236
1237=begin original
1238
1239These are the versions that normal modules will use. Can contain as
1240many subversions as required. In particular, those using RCS/CVS can
1241use the following:
1242
1243=end original
1244
1245これらは通常のモジュールが使うバージョンです。
1246必要なだけ多くの下位バージョンを含むことができます。
1247特に、RCS/CVS を使っている人は以下のコードを使うことができます:
1248
1249 $VERSION = version->new(qw$Revision: 2.7 $);
1250
1251=begin original
1252
1253and the current RCS Revision for that file will be inserted
1254automatically. If the file has been moved to a branch, the Revision
1255will have three or more elements; otherwise, it will have only two.
1256This allows you to automatically increment your module version by
1257using the Revision number from the primary file in a distribution, see
1258L<ExtUtils::MakeMaker/"VERSION_FROM">.
1259
1260=end original
1261
1262これでそのファイルに対する現在の RCS Revision が自動的に挿入されます。
1263もしファイルがブランチに移動されれば Revision は 3 つかそれ以上の要素を
1264持ち、そうでなければ 2 つのみを持つでしょう。
1265これはディストリビューション内のプライマリファイルから Revision 番号を
1266使うことでモジュールバージョンを自動的にインクリメントすることを
1267可能にします (L<ExtUtils::MakeMaker/"VERSION_FROM"> を参照)。
1268
1269=item * Alpha Versions
1270
1271638(αバージョン)
1272639
1273640=begin original
1274641
1275For module authors using CPAN, the convention has been to note
642For module authors using CPAN, the convention has been to note unstable
1276unstable releases with an underscore in the version string, see
643releases with an underscore in the version string. (See L<CPAN>.) version.pm
1277L<CPAN>. Alpha releases will test as being newer than the more recent
644follows this convention and alpha releases will test as being newer than the
1278stable release, and less than the next stable release. For example:
645more recent stable release, and less than the next stable release. For
646dotted-decimal versions, only the last element may be separated by an
647underscore:
1279648
1280649=end original
1281650
1282651CPAN を使用しているモジュール作者の間で、不安定なリリースを示すために
1283バージョン文字列内にアンダースコアを付ける慣習ができています (L<CPAN> を
652バージョン文字列内にアンダースコアを付ける慣習ができています
1284参照)
653(L<CPAN> を参照。)
1285αリリースは、その直前の安定リリースよりも新しく、次の安定リリースよりも
654version.pm はこの慣例に従い、αリリースは、その直前の安定リリースよりも
1286小さく判定されます。
655新しく、次の安定リリースよりも小さく判定されます。
1287例えば:
656ドット付き 10 進数バージョンでは、最後の要素のみが下線で分離されます:
1288657
1289 $alphaver = version->new("12.03_01"); # must be quoted
658 # Declaring
659 use version 0.77; our $VERSION = version->declare("v1.2_3");
1290660
1291=begin original
661 # Parsing
662 $v1 = version->parse("v1.2_3");
663 $v1 = version->parse("1.002_003");
1292664
1293obeys the relationship
665=head1 OBJECT METHODS
1294666
1295=end original
667(オブジェクトメソッド)
1296668
1297これは次の関係に従います。
669=head2 is_alpha()
1298670
1299 12.03 < $alphaver < 12.04
1300
1301671=begin original
1302672
1303Alpha versions with a single decimal point will be treated exactly as if
673True if and only if the version object was created with a underscore, e.g.
1304they were L<Numeric Versions>, for parsing and output purposes. The
1305underscore will be output when an alpha version is stringified, in the same
1306place as it was when input.
1307674
1308675=end original
1309676
1310小数点を 1 つ持つαバージョンは、パースと出力おいて、完全
677バージョンオブジェクトが下線付きで作られた場合のみ真なります; 例えば
1311L<Numeric Versions> であるかのように扱われます。
1312αバージョンが文字列化されたときには、アンダースコアが入力時と同じ位置に
1313出力されます。
1314678
1315=begin original
679 version->parse('1.002_03')->is_alpha; # TRUE
680 version->declare('1.2.3_4')->is_alpha; # TRUE
1316681
1317Alpha versions with more than a single decimal point will be treated
682=head2 is_qv()
1318exactly as if they were L<Extended Versions>, and will display without any
1319trailing (or leading) zeros, in the L<Version Normal> form. For example,
1320683
1321=end original
1322
13232 つ以上の小数点を持つαバージョンは完全に L<Extended Versions> で
1324あるかのように取り扱われ、バージョンの L<Normal form> で、末尾(あるいは
1325先頭)のゼロ無しで表示されます。
1326例えば:
1327
1328 $newver = version->new("12.3.1_1");
1329 print $newver; # v12.3.1_1
1330
1331=back
1332
1333=head2 Replacement UNIVERSAL::VERSION
1334
1335(代替 UNIVERSAL::VERSION)
1336
1337684=begin original
1338685
1339In addition to the version objects, this modules also replaces the core
686True only if the version object is a dotted-decimal version, e.g.
1340UNIVERSAL::VERSION function with one that uses version objects for its
1341comparisons. The return from this operator is always the stringified form,
1342but the warning message generated includes either the stringified form or
1343the normal form, depending on how it was called.
1344687
1345688=end original
1346689
1347バージョンオブジェクトに加えて、このモジュルは比較ためコア
690バージョンオブジェクトがドット付き 10 進数バジョン場合にのみ真になります;
1348UNIVERSAL::VERSION 関数をバージョンオブジェクトを使うものに
691例えば
1349置き換えることも行います。
1350この演算子から返されるものは常に文字列化された形式ですが、
1351生成された警告メッセージは、どのように呼び出されたかに依存して、
1352文字列化形式か Normal Form のどちらかになります。
1353692
1354=begin original
693 version->parse('v1.2.0')->is_qv; # TRUE
694 version->declare('v1.2')->is_qv; # TRUE
695 qv('1.2')->is_qv; # TRUE
696 version->parse('1.2')->is_qv; # FALSE
1355697
1356For example:
698=head2 normal()
1357699
1358=end original
1359
1360例えば:
1361
1362 package Foo;
1363 $VERSION = 1.2;
1364
1365 package Bar;
1366 $VERSION = "1.3.5"; # works with all Perl's (since it is quoted)
1367
1368 package main;
1369 use version;
1370
1371 print $Foo::VERSION; # prints 1.2
1372
1373 print $Bar::VERSION; # prints 1.003005
1374
1375 eval "use foo 10";
1376 print $@; # prints "foo version 10 required..."
1377 eval "use foo 1.3.5; # work in Perl 5.6.1 or better
1378 print $@; # prints "foo version 1.3.5 required..."
1379
1380 eval "use bar 1.3.6";
1381 print $@; # prints "bar version 1.3.6 required..."
1382 eval "use bar 1.004"; # note numeric version
1383 print $@; # prints "bar version 1.004 required..."
1384
1385
1386700=begin original
1387701
1388IMPORTANT NOTE: This may mean that code which searches for a specific
702Returns a string with a standard 'normalized' dotted-decimal form with a
1389string (to determine whether a given module is available) may need to be
703leading-v and at least 3 components.
1390changed. It is always better to use the built-in comparison implicit in
1391C<use> or C<require>, rather than manually poking at C<class->VERSION>
1392and then doing a comparison yourself.
1393704
1394705=end original
1395706
1396重要な注意: (与えられたモジュールが利用可能かどうかを決定するために)
707先頭の v と最低 3 要素ある標準の「正規化された」ドット付き 10 進数形式の
1397特定の文字列を検索するためのコードは変更が必要かもれないことを
708文字列をます。
1398意味します。
1399手動で C<class->VERSION> を使ってから自分で比較を行うより、
1400C<use> や C<require> で暗黙に使われる組み込みの比較を使う方が
1401常に優れています。
1402709
1403=begin original
710 version->declare('v1.2')->normal; # v1.2.0
711 version->parse('1.2')->normal; # v1.200.0
1404712
1405The replacement UNIVERSAL::VERSION, when used as a function, like this:
713=head2 numify()
1406714
1407=end original
1408
1409UNIVERSAL::VERSION の代替物は、以下のように関数として使われた際:
1410
1411 print $module->VERSION;
1412
1413715=begin original
1414716
1415will also exclusively return the stringified form. See L<Stringification>
717Returns a value representing the object in a pure decimal form without
1416for more details.
718trailing zeroes.
1417719
1418720=end original
1419721
1420これも文字列化形式のを返します。
722末尾のゼロなしの純粋な 10 進数形式のオブジェクトで表現される値を返します。
1421更なる詳細については L<Stringification> を参照してください。
1422723
1423=head1 SUBCLASSING
724 version->declare('v1.2')->numify; # 1.002
725 version->parse('1.2')->numify; # 1.2
1424726
1425(サブクラス化)
727=head2 stringify()
1426728
1427729=begin original
1428730
1429This module is specifically designed and tested to be easily subclassed.
731Returns a string that is as close to the original representation as possible.
1430In practice, you only need to override the methods you want to change, but
732If the original representation was a numeric literal, it will be returned the
1431you have to take some care when overriding new() (since that is where all
733way perl would normally represent it in a string. This method is used whenever
1432of the parsing takes place). For example, this is a perfect acceptable
734a version object is interpolated into a string.
1433derived class:
1434735
1435736=end original
1436737
1437モジュールは簡単サブクラス化ができるように明確に設計やテストがさ
738表現にできるだけ近い文字列を返します。
1438ていま
739元の表現が数値リテラルなら、perl が通常こを文字列で表現る方法で値を
1439実際には、変更たいメソッドをオーバーライドるだけで OK ですが、
740
1440new() をオーバーライする際に注意が必要です (パ全て行われ
741このメソッドはジョンオブジェクト文字列に変換された時に使われます。
1441場所なので)。
1442例えば、これは完全に条件を満たしている派生クラスです:
1443742
1444 package myversion;
743 version->declare('v1.2')->stringify; # v1.2
1445 use base version;
744 version->parse('1.200')->stringify; # 1.200
1446 sub new {
745 version->parse(1.02_30)->stringify; # 1.023
1447 my($self,$n)=@_;
1448 my $obj;
1449 # perform any special input handling here
1450 $obj = $self->SUPER::new($n);
1451 # and/or add additional hash elements here
1452 return $obj;
1453 }
1454746
1455=begin original
747=head1 EXPORTED FUNCTIONS
1456748
1457See also L<version::AlphaBeta> on CPAN for an alternate representation of
749(エクスポートされる関数)
1458version strings.
1459750
1460=end original
751=head2 qv()
1461752
1462バージョン文字列の代替の表現形式については CPAN の L<version::AlphaBeta> も
1463参照してください。
1464
1465753=begin original
1466754
1467B<NOTE:> Although the L<qv> operator is not a true class method, but rather a
755This function is no longer recommended for use, but is maintained for
1468function exported into the caller's namespace, a subclass of version will
756compatibility with existing code. If you do not want to have it exported
1469inherit an import() function which will perform the correct magic on behalf
757to your namespace, use this form:
1470of the subclass.
1471758
1472759=end original
1473760
1474B<注意>: L<qv> 演算子は真クラスメソッドでなくむしろ呼び出し元
761関数もはや使用を推奨されませんが既にあるコード互換性のために
1475名前空間にエクスポートされた関数で、version のサブクラスは、その
762保守されています。
1476サブに代わって正しいマジックを実行する import() 関数を継承します
763名前空間にこれをエクスポートたくなときは、以下のようにします:
1477764
1478=head1 EXPORT
765 use version 0.77 ();
1479766
1480=begin original
1481
1482qv - Extended Version initialization operator
1483
1484=end original
1485
1486qv - 拡張バージョン初期化演算子
1487
1488767=head1 AUTHOR
1489768
1490769John Peacock E<lt>jpeacock@cpan.orgE<gt>
1491770
1492771=head1 SEE ALSO
1493772
773L<version::Internal>.
774
1494775L<perl>.
1495776
1496777=begin meta
1497778
1498779Translate: Kenji Inoue <kenz@oct.zaq.ne.jp> (0.70)
1499Update: Kentaro Shirakata <argrath@ub32.org> (0.74)
780Update: SHIRAKATA Kentaro <argrath@ub32.org> (0.74-)
781Status: completed
1500782
1501783=end meta
1502784
1503785=cut