Alien::...::Basic(3)
π Alien::Build::Version::Basic π
okay bestie, so this is Alien::Build::Version::Basic(3) β a very basic version object for Alien::Build, and honestly? it's giving "small but mighty." come sit with me, we're gonna get through this together π«Ά
VERSION: version 2.88 β¨
πΈ SYNOPSIS πΈ
OO interface, bestie β the fancy way:
use Alien::Build::Version::Basic;
my $version = Alien::Build::Version::Basic->new('1.2.3');
if($version > '1.2.2') # true
{
...
}
Function interface β the chill way:
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
like look at that sort. 1.2.2, 1.2.3, 2.1. it just knows. periodt π
β¨ DESCRIPTION β¨
So this module gives you a very basic class for comparing versions. and ngl, version comparison on CPAN is already a crowded space β everyone and their group chat has an opinion.
Parts of Alien::Build already use Sort::Versions, which is totally fine for sorting versions. but sometimes you don't wanna sort, you wanna check if versions match exact values. and the best candidates out there (like Sort::Versions on CPAN) will compare 1.2.3.0 and 1.2.3 as being different. π this class compares those two as the same. iconic behavior honestly.
β οΈ but bestie, hear me β this class is also quite limited. it only works with version schemes using a dotted version numbers, or real numbers with a fixed number of digits. versions with: dashes, letters, hex digits, or anything else are not supported. no cap, don't try it.
This class overloads both <=> and cmp to compare the version the way you'd expect for version numbers. so you can compare versions like numbers, or sort them using sort. it's giving main character energy:
if(version($v1) > version($v2))
{
...
}
my @sorted = sort map { version($_) } @unsorted;
and it also overloads "" to stringify as whatever string value you passed to the constructor. so "$version" just hands you back your original string, no drama. π
π CONSTRUCTOR π
new
my $version = Alien::Build::Version::Basic->new($value);
This is the long form of the constructor β use it if you don't want to import anything into your namespace. very "I keep to myself" of you. π
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. no freebies here bestie, you gotta ask.
π METHODS π
as_string
my $string = $version->as_string;
my $string = "$version";
Returns the string representation of the version object. that's it, that's the whole vibe. β¨
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. so predictable, so reliable, so slay.
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. flexible queen. π
π¦ SEE ALSO π¦
Sort::Versionsβ Good, especially if you have to support rpm style versions (like1.2.3-2-b) or don't care if trailing zeros (1.2.3vs1.2.3.0) are treated as different values.versionβ Problematic for historical reasons. π iykyk.
π AUTHOR π
Author: Graham Ollis <plicease@cpan.org>
Contributors, aka the whole friend group, the real ones:
- 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)
- Florian Weimer
- Marcel Telka (mtelka)
every single one of them. we love to see it. π
π COPYRIGHT AND LICENSE π
This software is copyright (c) 2011-2022 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.
okay that's the whole page bestie, you ate that π this one's perl v5.42.3, dated 2026-09-21, from the Alien::...::Basic(3) manual page. go forth and compare versions responsibly π§ β¨
π¦ where this page comes from
- fedora 43: perl-Alien-Build 2.88-1.fc43 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- fedora 44: perl-Alien-Build 2.88-1.fc44 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms