-
-
13 Mar 2022 17:23:52 UTC
- Distribution: Alien-Build
- Module version: 2.48
- Source (raw)
- Browse (raw)
- Changes
- Homepage
- How to Contribute
- Repository
- Issues
- Testers (1499 / 58 / 1)
- Kwalitee
Bus factor: 4- % Coverage
- License: perl_5
- Perl: v5.8.4
- Activity
24 month- Tools
- Download (313.13KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
and 29 contributors-
Joel Berger
- Diab Jerius (DJERIUS)
- Roy Storey (KIWIROY)
- Ilya Pavlov
- David Mertens (run4flat)
- Mark Nunberg (mordy, mnunberg)
- Christian Walde (Mithaldu)
- Brian Wightman (MidLifeXis)
- Zaki Mughal (zmughal)
- mohawk (mohawk2, ETJ)
- Vikas N Kumar (vikasnkumar)
- Flavio Poletti (polettix)
- Salvador Fandiño (salva)
- Gianni Ceccarelli (dakkar)
- Pavel Shaydo (zwon, trinitum)
- Kang-min Liu (劉康民, gugod)
- Nicholas Shipp (nshp)
- Juan Julián Merelo Guervós (JJ)
- Joel Berger (JBERGER)
- Petr PÃsaÅ™ (ppisar)
- Lance Wicks (LANCEW)
- Ahmad Fatoum (a3f, ATHREEF)
- José JoaquÃn Atria (JJATRIA)
- Duke Leto (LETO)
- Shoichi Kaji (SKAJI)
- Shawn Laffan (SLAFFAN)
- Paul Evans (leonerd, PEVANS)
- Håkon Hægland (hakonhagland, HAKONH)
- nick nauwelaerts (INPHOBIA)
NAME
Alien::Build::Version::Basic - Very basic version object for Alien::Build
VERSION
version 2.48
SYNOPSIS
OO interface:
use Alien::Build::Version::Basic; my $version = Alien::Build::Version::Basic->new('1.2.3'); if($version > '1.2.2') # true { ... }
Function interface:
use Alien::Build::Version::Basic qw( version ); if(version('1.2.3') > version('1.2.2')) # true { ... } my @sorted = sort map { version($_) } qw( 2.1 1.2.3 1.2.2 ); # will come out in the order 1.2.2, 1.2.3, 2.1
DESCRIPTION
This module provides a very basic class for comparing versions. This is already a crowded space on CPAN. Parts of Alien::Build already use Sort::Versions, which is fine for sorting versions. Sometimes you need to compare to see if versions match exact values, and the best candidates (such as Sort::Versions on CPAN compare
1.2.3.0
and1.2.3
as being different. This class compares those two as the same.This class is also quite limited, in that it only works with version schemes using a doted version numbers or real numbers with a fixed number of digits. Versions with: dashes, letters, hex digits, or anything else are not supported.
This class overloads both
<=>
andcmp
to compare the version in the way that you would expect for version numbers. This way you can compare versions like numbers, or sort them using sort.if(version($v1) > version($v2)) { ... } my @sorted = sort map { version($_) } @unsorted;
it also overloads
""
to stringify as whatever string value you passed to the constructor.CONSTRUCTOR
new
my $version = Alien::Build::Version::Basic->new($value);
This is the long form of the constructor, if you don't want to import anything into your namespace.
version
my $version = version($value);
This is the short form of the constructor, if you are sane. It is NOT exported by default so you will have to explicitly import it.
METHODS
as_string
my $string = $version->as_string; my $string = "$version";
Returns the string representation of the version object.
cmp
my $bool = $version->cmp($other); my $bool = $version <=> $other; my $bool = $version cmp $other;
Returns
-1
,0
or1
just like the regular<=>
andcmp
operators. Although$version
must be a version object,$other
may be either a version object, or a string that could be used to create a valid version object.SEE ALSO
- Sort::Versions
-
Good, especially if you have to support rpm style versions (like
1.2.3-2-b
) or don't care if trailing zeros (1.2.3
vs1.2.3.0
) are treated as different values. - version
-
Problematic for historical reasons.
AUTHOR
Author: Graham Ollis <plicease@cpan.org>
Contributors:
Diab Jerius (DJERIUS)
Roy Storey (KIWIROY)
Ilya Pavlov
David Mertens (run4flat)
Mark Nunberg (mordy, mnunberg)
Christian Walde (Mithaldu)
Brian Wightman (MidLifeXis)
Zaki Mughal (zmughal)
mohawk (mohawk2, ETJ)
Vikas N Kumar (vikasnkumar)
Flavio Poletti (polettix)
Salvador Fandiño (salva)
Gianni Ceccarelli (dakkar)
Pavel Shaydo (zwon, trinitum)
Kang-min Liu (劉康民, gugod)
Nicholas Shipp (nshp)
Juan Julián Merelo Guervós (JJ)
Joel Berger (JBERGER)
Petr Písař (ppisar)
Lance Wicks (LANCEW)
Ahmad Fatoum (a3f, ATHREEF)
José Joaquín Atria (JJATRIA)
Duke Leto (LETO)
Shoichi Kaji (SKAJI)
Shawn Laffan (SLAFFAN)
Paul Evans (leonerd, PEVANS)
Håkon Hægland (hakonhagland, HAKONH)
nick nauwelaerts (INPHOBIA)
COPYRIGHT AND LICENSE
This software is copyright (c) 2011-2020 by Graham Ollis.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
Module Install Instructions
To install Alien::Build, copy and paste the appropriate command in to your terminal.
cpanm Alien::Build
perl -MCPAN -e shell install Alien::Build
For more information on module installation, please visit the detailed CPAN module installation guide.