Acme-CPANModules-VersionNumber-Perl
view release on metacpan or search on metacpan
Acme::CPANModules::VersionNumber::Perl (from Perl distribution
Acme-CPANModules-VersionNumber-Perl), released on 2023-10-31.
DESCRIPTION
The core module version (a.k.a. version.pm) should be your first go-to
module when dealing with Perl version numbers. Other modules can also
help in some aspects. Modules mentioned here include: Perl::Version,
Versioning::Scheme::Perl.
Version numbers in Perl
There are two styles of version numbers used in the Perl world (i.e. for
the versioning of perl interpreter itself and for versioning Perl
modules): decimal (x.y) or dotted decimals (x.y.z or even more parts;
the "v" prefix forces dotted decimal to avoid ambiguity when there is
only a single dot, e.g. v1.2).
The former variant offers simplicity since version number can mostly be
represented by a floating point number (quoting as string is still
recommended to retain all precision and trailing zeros) and comparing
versions can be done numerically. However they are often very limited so
in those cases a dotted decimal variant can be used. For example the
while 0.2.1 or 0.02.1 (dotted decimal) numifies to 0.002001. Hence,
going from 0.02 to 0.02.1 will actually *decrease* your version number.
I recommend using x.yyy if you use decimal form, i.e. start from 0.001
and not 0.01. It will support you going smoothly to dotted decimal if
you decide to do it one day.
The numification is also problematic when a number part is > 999, e.g.
1.2.1234. This breaks version comparison when comparison is done with
version->parse().
Aside from the abovementioned two styles, there is another: CPAN
distributions/modules can add an underscore in the last part of the
version number to signify alpha/dev/trial release, e.g. 1.2.3_01. PAUSE
will not index such releases, so testers will need to specify an
explicit version number to install, e.g. "cpanm Foo@1.2.3_01". In some
cases you need to pay attention when comparing this kind of version
numbers.
Checking if a string is a valid version number
To check if a string is a valid Perl version number, you can do:
lib/Acme/CPANModules/VersionNumber/Perl.pm view on Meta::CPAN
summary => 'List of libraries for working with Perl version numbers (or version strings)',
description => <<'_',
The core module <pm:version> (a.k.a. version.pm) should be your first go-to
module when dealing with Perl version numbers. Other modules can also help in
some aspects. Modules mentioned here include: <pm:Perl::Version>,
<pm:Versioning::Scheme::Perl>.
## Version numbers in Perl
There are two styles of version numbers used in the Perl world (i.e. for the
versioning of perl interpreter itself and for versioning Perl modules): decimal
(x.y) or dotted decimals (x.y.z or even more parts; the "v" prefix forces dotted
decimal to avoid ambiguity when there is only a single dot, e.g. v1.2).
The former variant offers simplicity since version number can mostly be
represented by a floating point number (quoting as string is still recommended
to retain all precision and trailing zeros) and comparing versions can be done
numerically. However they are often very limited so in those cases a dotted
decimal variant can be used. For example the perl interpreter itself uses x.y.z
convention.
lib/Acme/CPANModules/VersionNumber/Perl.pm view on Meta::CPAN
compared using version->parse(). Another gotcha is when a module author decides
to go from 0.02 to 0.2.1 or 0.02.1. 0.02 (a decimal form) numifies to 0.02 while
0.2.1 or 0.02.1 (dotted decimal) numifies to 0.002001. Hence, going from 0.02 to
0.02.1 will actually *decrease* your version number. I recommend using x.yyy if
you use decimal form, i.e. start from 0.001 and not 0.01. It will support you
going smoothly to dotted decimal if you decide to do it one day.
The numification is also problematic when a number part is > 999, e.g. 1.2.1234.
This breaks version comparison when comparison is done with version->parse().
Aside from the abovementioned two styles, there is another: CPAN
distributions/modules can add an underscore in the last part of the version
number to signify alpha/dev/trial release, e.g. 1.2.3_01. PAUSE will not index
such releases, so testers will need to specify an explicit version number to
install, e.g. `cpanm Foo@1.2.3_01`. In some cases you need to pay attention when
comparing this kind of version numbers.
## Checking if a string is a valid version number
To check if a string is a valid Perl version number, you can do:
lib/Acme/CPANModules/VersionNumber/Perl.pm view on Meta::CPAN
=head1 DESCRIPTION
The core module L<version> (a.k.a. version.pm) should be your first go-to
module when dealing with Perl version numbers. Other modules can also help in
some aspects. Modules mentioned here include: L<Perl::Version>,
L<Versioning::Scheme::Perl>.
=head2 Version numbers in Perl
There are two styles of version numbers used in the Perl world (i.e. for the
versioning of perl interpreter itself and for versioning Perl modules): decimal
(x.y) or dotted decimals (x.y.z or even more parts; the "v" prefix forces dotted
decimal to avoid ambiguity when there is only a single dot, e.g. v1.2).
The former variant offers simplicity since version number can mostly be
represented by a floating point number (quoting as string is still recommended
to retain all precision and trailing zeros) and comparing versions can be done
numerically. However they are often very limited so in those cases a dotted
decimal variant can be used. For example the perl interpreter itself uses x.y.z
convention.
lib/Acme/CPANModules/VersionNumber/Perl.pm view on Meta::CPAN
compared using version->parse(). Another gotcha is when a module author decides
to go from 0.02 to 0.2.1 or 0.02.1. 0.02 (a decimal form) numifies to 0.02 while
0.2.1 or 0.02.1 (dotted decimal) numifies to 0.002001. Hence, going from 0.02 to
0.02.1 will actually I<decrease> your version number. I recommend using x.yyy if
you use decimal form, i.e. start from 0.001 and not 0.01. It will support you
going smoothly to dotted decimal if you decide to do it one day.
The numification is also problematic when a number part is > 999, e.g. 1.2.1234.
This breaks version comparison when comparison is done with version->parse().
Aside from the abovementioned two styles, there is another: CPAN
distributions/modules can add an underscore in the last part of the version
number to signify alpha/dev/trial release, e.g. 1.2.3_01. PAUSE will not index
such releases, so testers will need to specify an explicit version number to
install, e.g. C<cpanm Foo@1.2.3_01>. In some cases you need to pay attention when
comparing this kind of version numbers.
=head2 Checking if a string is a valid version number
To check if a string is a valid Perl version number, you can do:
( run in 1.392 second using v1.01-cache-2.11-cpan-49f99fa48dc )