URI::V...ersion(3pm)
π URI::VersionRange::Version β the lil base class that makes version schemes go brrr π
okay bestie, so this is a 3pm Perl manual page β user contributed Perl docs, the whole vibe β for URI::VersionRange::Version, aka the version scheme helper class. Think of it as the glow-up base class that every version scheme inherits its whole personality from. β¨
πΈ NAME πΈ
URI::VersionRange::Version β Version scheme helper class. that's it, that's the name, no notes. π
β¨ SYNOPSIS β¨
here's the vibe in code, bestie β a whole scheme class built on top, then some actual usage:
package URI::VersionRange::Scheme::generic {
use Version::libversion::XS qw(version_compare2);
use parent 'URI::VersionRange::Version';
use overload ('cmp' => \&compare, '<=>' => \&compare, fallback => 1);
sub compare {
my ($left, $right) = @_;
return version_compare2($left->[0], $right->[0]);
}
}
my $vers = URI::VersionRange->from_string('vers:generic/>v1.00|!=v2.10|<=v3.00');
if ($vers->contains('v2.50')) {
# do stuff
}
likeβ¦ the contains check is giving main character energy fr fr. π₯
π¦ DESCRIPTION π¦
so basically: this is a base class for the version scheme helper. that's the whole assignment. it's the parent everybody else extends. π
π OBJECT-ORIENTED INTERFACE π
new
$v = URI::VersionRange::Version->new( $value )
creates a brand new URI::VersionRange::Version instance using the version value you hand it. fresh out the box, no cap. π
compare
$v->compare
compares the version. that's the job. βοΈ
from_native
$v->from_native( $native_range )
converts the scheme's native range into a VERS string. translation service, but make it versions. π
load
$class = URI::VersionRange::Version->load( $scheme )
loads the scheme class. boom, loaded. β¨
π§ HOW TO CREATE A NEW SCHEME COMPARATOR CLASS π§
want your own scheme? iconic, here's the recipe:
- create a new package using the naming convention
URI::VersionRange::Scheme::<scheme>by extendingURI::VersionRange::Version. - implement the
compare($left, $right)subroutine with the algorithm required by thescheme.
the $left and $right arguments of compare are ARRAY and have as their first element the value of the version to be compared. yep, arrayrefs, don't fight it. π
- overload
'<=>'andcmpoperators using thecomparesubroutine β MANDATORY (not optional, not a suggestion, bestie, it is required π). - implement the
from_native($self, $native)subroutine to convert the native range of the scheme into a VERS string.
and here's an example that implements a comparator for the generic scheme using the Version::libversion::XS module:
package URI::VersionRange::Scheme::generic {
use Version::libversion::XS;
use parent 'URI::VersionRange::Version';
use overload ('cmp' => \&compare, '<=>' => \&compare, fallback => 1);
sub compare {
my ($left, $right) = @_;
return version_compare2($left->[0], $right->[0]);
}
}
and here's another example, this time for the rpm scheme using the RPM4 module:
package URI::VersionRange::Scheme::rpm {
use RPM4;
use parent 'URI::VersionRange::Version';
use overload ('cmp' => \&compare, '<=>' => \&compare, fallback => 1);
sub compare {
my ($left, $right) = @_;
return rpmvercmp($left->[0], $right->[0]);
}
}
two examples, two vibes, both slay. π
π«Ά SUPPORT π«Ά
π Bugs / Feature Requests π
please report any bugs or feature requests through the issue tracker at <https://github.com/giterlizzi/perl-URI-PackageURL/issues>. you will be notified automatically of any progress on your issue. so like, you'll know. π
π¦ Source Code π¦
this is open source software. the code repository is available for public review and contribution under the terms of the license.
<https://github.com/giterlizzi/perl-URI-PackageURL>
git clone https://github.com/giterlizzi/perl-URI-PackageURL.git
clone it, bestie, go be part of history. π
π AUTHOR π
- Giuseppe Di Terlizzi <gdt@cpan.org>
π LICENSE AND COPYRIGHT π
this software is copyright (c) 2022-2026 by Giuseppe Di Terlizzi.
this is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
free software, the same terms as Perl 5 itself β go wild, but responsibly. π«Ά
and that's the whole page, bestie!! perl v5.40.1, dated 2026-01-31, brought to you by User Contributed Perl Documentation. mwah, go write a scheme class, i believe in you πππ¦
π¦ where this page comes from
- ubuntu resolute: liburi-packageurl-perl 2.25-1 Β· Artistic-2.0
- ubuntu stonking: liburi-packageurl-perl 2.25-1 Β· Artistic-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms