Go to main content

man pages section 3: Library Interfaces and Headers

Exit Print View

Updated: Wednesday, July 27, 2022
 
 

Alien::Build::Version::Basic (3)

Name

Alien::Build::Version::Basic - Very basic version object for Alien::Build

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

User Contributed Perl Documentation
                                               Alien::Build::Version::Basic(3)



NAME
       Alien::Build::Version::Basic - Very basic version object for
       Alien::Build

VERSION
       version 1.89

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 and 1.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 "<=>" and "cmp" 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 or 1 just like the regular "<=>" and "cmp" 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.


ATTRIBUTES
       See attributes(7) for descriptions of the following attributes:


       +---------------+--------------------------------+
       |ATTRIBUTE TYPE |        ATTRIBUTE VALUE         |
       +---------------+--------------------------------+
       |Availability   | library/perl-5/alien-build-532 |
       +---------------+--------------------------------+
       |Stability      | Volatile                       |
       +---------------+--------------------------------+

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 vs 1.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 Fandio (salva)

       Gianni Ceccarelli (dakkar)

       Pavel Shaydo (zwon, trinitum)

       Kang-min Liu (, gugod)

       Nicholas Shipp (nshp)

       Juan Julin Merelo Guervs (JJ)

       Joel Berger (JBERGER)

       Petr Pisar (ppisar)

       Lance Wicks (LANCEW)

       Ahmad Fatoum (a3f, ATHREEF)

       Jos Joaqun Atria (JJATRIA)

       Duke Leto (LETO)

       Shoichi Kaji (SKAJI)

       Shawn Laffan (SLAFFAN)

       Paul Evans (leonerd, PEVANS)

COPYRIGHT AND LICENSE
       This software is copyright (c) 2011-2019 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.



NOTES
       Source code for open source software components in Oracle Solaris can
       be found at https://www.oracle.com/downloads/opensource/solaris-source-
       code-downloads.html.

       This software was built from source available at
       https://github.com/oracle/solaris-userland.  The original community
       source was downloaded from
       http://www.cpan.org/authors/id/P/PL/PLICEASE/Alien-Build-1.89.tar.gz.

       Further information about this software can be found on the open source
       community website at http://search.cpan.org/dist/Alien-Build/.



perl v5.32.0                      2019-09-25
                                               Alien::Build::Version::Basic(3)