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 (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. πŸ’€ 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. 🌈


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