⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 version.pod

📁 视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.
💻 POD
📖 第 1 页 / 共 2 页
字号:
=head1 NAMEversion - Perl extension for Version Objects=head1 SYNOPSIS  use version;  $version = version->new("12.2.1"); # must be quoted for Perl < 5.8.1  print $version; 		# v12.2.1  print $version->numify; 	# 12.002001  if ( $version gt "12.2" )	# true  $alphaver = version->new("1.02_03"); # must be quoted!  print $alphaver;		# 1.02_0300  print $alphaver->is_alpha();  # true    $ver = qv("1.2.0");           # v1.2.0  $perlver = version->new(5.005_03); # must not be quoted!  print $perlver;		# 5.005030=head1 DESCRIPTIONOverloaded version objects for all modern versions of Perl.  This moduleimplements all of the features of version objects which will be partof Perl 5.10.0.=head2 BEST PRACTICESIf you intend for your module to be used by different releases of Perl,and/or for your $VERSION scalar to mean what you think it means, there are a few simple rules to follow:=over 4=item * Be consistentWhichever of the two types of version objects that you choose to employ, you should stick to either L<Numeric Versions> or L<Extended Versions>and not mix them together.  While this is I<possible>, it is very confusing to the average user.If you intend to use L<Extended Versions>, you are strongly encouraged to use the L<qv()> operator with a quoted term, e.g.:  use version; our $VERSION = qv("1.2.3");on a single line as above. At the very least, decide on which of the several ways to initialize your version objects you prefer and stick with it.  It is also best to be explicit about what value you intend to assign your version object and to not rely on hidden behavior of the parser. =item * Be carefulIf you are using Module::Build or ExtUtils::MakeMaker, so that you canrelease your module to CPAN, you have to recognize that neither of thoseprograms completely handles version objects natively (yet).  If you useversion objects with Module::Build, you should add an explicit dependencyto the release of version.pm in your Build.PL:  my $builder = Module::Build->new(     ...     requires => {         ... ,         'version'    => 0.50,	 ...,     },     ...  );and it should Just Work(TM).  Module::Build will [hopefully soon] include full support for version objects; there are no current plans to patch ExtUtils::MakeMaker to support version objects.=back=head2 Using modules that use version.pmAs much as possible, the version.pm module remains compatible with allcurrent code.  However, if your module is using a module that has definedC<$VERSION> using the version class, there are a couple of things to beaware of.  For purposes of discussion, we will assume that we have thefollowing module installed:  package Example;  use version;  $VERSION = qv('1.2.2');  ...module code here...  1;=over 4=item Numeric versions always workCode of the form:  use Example 1.002003;will always work correctly.  The C<use> will perform an automaticC<$VERSION> comparison using the floating point number given as the firstterm after the module name (e.g. above 1.002.003).  In this case, theinstalled module is too old for the requested line, so you would see anerror like:  Example version 1.002003 (v1.2.3) required--this is only version 1.002002 (v1.2.2)...=item Extended version work sometimesWith Perl >= 5.6.2, you can also use a line like this:  use Example 1.2.3;and it will again work (i.e. give the error message as above), even withreleases of Perl which do not normally support v-strings (see L<What aboutv-strings> below).  This has to do with that fact that C<use> only checksto see if the second term I<looks like a number> and passes that to thereplacement L<UNIVERSAL::VERSION>.  This is not true in Perl 5.005_04,however, so you are B<strongly encouraged> to always use a numeric versionin your code, even for those versions of Perl which support the extendedversion.=back=head2 What IS a versionFor the purposes of this module, a version "number" is a sequence ofpositive integer values separated by one or more decimal points and optionally a single underscore.  This corresponds to what Perl itself uses for a version, as well as extending the "version as number" that is discussed in the various editions of the Camel book.There are actually two distinct kinds of version objects:=over 4=item * Numeric VersionsAny initial parameter which "looks like a number", see L<NumericVersions>.  This also covers versions with a single decimal point anda single embedded underscore, see L<Numeric Alpha Versions>, even thoughthese must be quoted to preserve the underscore formatting.=item * Extended VersionsAny initial parameter which contains more than one decimal pointand an optional embedded underscore, see L<Extended Versions>.  This is what is commonly used in most open source software as the "external"version (the one used as part of the tag or tarfile name).  The useof the exported L<qv()> function also produces this kind of versionobject.=backBoth of these methods will produce similar version objects, in thatthe default stringification will yield the version L<Normal Form> only if required:  $v  = version->new(1.002);     # 1.002, but compares like 1.2.0  $v  = version->new(1.002003);  # 1.002003  $v2 = version->new("1.2.3");   # v1.2.3In specific, version numbers initialized as L<Numeric Versions> willstringify as they were originally created (i.e. the same string that waspassed to C<new()>.  Version numbers initialized as L<Extended Versions>will be stringified as L<Normal Form>.=head2 Numeric VersionsThese correspond to historical versions of Perl itself prior to 5.6.0,as well as all other modules which follow the Camel rules for the$VERSION scalar.  A numeric version is initialized with what looks likea floating point number.  Leading zeros B<are> significant and trailingzeros are implied so that a minimum of three places is maintainedbetween subversions.  What this means is that any subversion (digitsto the right of the decimal place) that contains less than three digitswill have trailing zeros added to make up the difference, but only forpurposes of comparison with other version objects.  For example:                                   # Prints     Equivalent to    $v = version->new(      1.2);    # 1.2        v1.200.0  $v = version->new(     1.02);    # 1.02       v1.20.0  $v = version->new(    1.002);    # 1.002      v1.2.0  $v = version->new(   1.0023);    # 1.0023     v1.2.300  $v = version->new(  1.00203);    # 1.00203    v1.2.30  $v = version->new( 1.002003);    # 1.002003   v1.2.3All of the preceding examples are true whether or not the input value is quoted.  The important feature is that the input value contains only a single decimal.  See also L<Alpha Versions> for how to handle IMPORTANT NOTE: As shown above, if your numeric version contains more than 3 significant digits after the decimal place, it will be split on each multiple of 3, so 1.0003 is equivalent to v1.0.300, due to the need to remain compatible with Perl's own 5.005_03 == 5.5.30 interpretation.  Any trailing zeros are ignored for mathematical comparison purposes.=head2 Extended VersionsThese are the newest form of versions, and correspond to Perl's ownversion style beginning with 5.6.0.  Starting with Perl 5.10.0,and most likely Perl 6, this is likely to be the preferred form.  Thismethod normally requires that the input parameter be quoted, although Perl's after 5.8.1 can use v-strings as a special form of quoting, butthis is highly discouraged.Unlike L<Numeric Versions>, Extended Versions have more thana single decimal point, e.g.:                                   # Prints  $v = version->new( "v1.200");    # v1.200.0  $v = version->new("v1.20.0");    # v1.20.0  $v = qv("v1.2.3");               # v1.2.3  $v = qv("1.2.3");                # v1.2.3  $v = qv("1.20");                 # v1.20.0In general, Extended Versions permit the greatest amount of freedomto specify a version, whereas Numeric Versions enforce a certainuniformity.  See also L<New Operator> for an additional method ofinitializing version objects.Just like L<Numeric Versions>, Extended Versions can be used as L<Alpha Versions>.=head2 Numeric Alpha VersionsThe one time that a numeric version must be quoted is when a alpha form isused with an otherwise numeric version (i.e. a single decimal point).  Thisis commonly used for CPAN releases, where CPAN or CPANPLUS will ignore alphaversions for automatic updating purposes.  Since some developers have usedonly two significant decimal places for their non-alpha releases, theversion object will automatically take that into account if the initializeris quoted.  For example Module::Example was released to CPAN with thefollowing sequence of $VERSION's:  # $VERSION    Stringified  0.01          0.01  0.02          0.02  0.02_01       0.02_01  0.02_02       0.02_02  0.03          0.03  etc.The stringified form of numeric versions will always be the same stringthat was used to initialize the version object.=head2 Object MethodsOverloading has been used with version objects to provide a naturalinterface for their use.  All mathematical operations are forbidden,since they don't make any sense for base version objects.  Consequently,there is no overloaded numification available.  If you want to use aversion object in a numeric context for some reason, see the L<numify>object method.=over 4=item * New OperatorLike all OO interfaces, the new() operator is used to initializeversion objects.  One way to increment versions when programming is touse the CVS variable $Revision, which is automatically incremented byCVS every time the file is committed to the repository.In order to facilitate this feature, the followingcode can be employed:  $VERSION = version->new(qw$Revision: 2.7 $);and the version object will be created as if the following codewere used:  $VERSION = version->new("v2.7");In other words, the version will be automatically parsed out of thestring, and it will be quoted to preserve the meaning CVS normallycarries for versions.  The CVS $Revision$ increments differently fromnumeric versions (i.e. 1.10 follows 1.9), so it must be handled as ifit were a L<Extended Version>.A new version object can be created as a copy of an existing versionobject, either as a class method:  $v1 = version->new(12.3);  $v2 = version->new($v1);or as an object method:  $v1 = version->new(12.3);  $v2 = $v1->new(12.3);and in each case, $v1 and $v2 will be identical.  NOTE: if you createa new object using an existing object like this:  $v2 = $v1->new();the new object B<will not> be a clone of the existing object.  In theexample case, $v2 will be an empty object of the same type as $v1.=back=over 4=item * qv()An alternate way to create a new version object is through the exportedqv() sub.  This is not strictly like other q? operators (like qq, qw),in that the only delimiters supported are parentheses (or spaces).  It isthe best way to initialize a short version without triggering the floatingpoint interpretation.  For example:  $v1 = qv(1.2);         # 1.2.0  $v2 = qv("1.2");       # also 1.2.0As you can see, either a bare number or a quoted string can usually be used interchangably, except in the case of a trailing zero, whichmust be quoted to be converted properly.  For this reason, it is stronglyrecommended that all initializers to qv() be quoted strings instead ofbare numbers.To prevent the C<qv()> function from being exported to the caller's namespace,either use version with a null parameter:  use version ();or just require version, like this:  require version;Both methods will prevent the import() method from firing and exporting theC<qv()> sub.  This is true of subclasses of version as well, seeL<SUBCLASSING> for details.=backFor the subsequent examples, the following three objects will be used:  $ver   = version->new("1.2.3.4"); # see "Quoting" below  $alpha = version->new("1.2.3_4"); # see "Alpha versions" below  $nver  = version->new(1.002);     # see "Numeric Versions" above

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -