URI::V...onRange(3pm)
π URI::VersionRange β the VERS era π
okay bestie, so this is URI::VersionRange(3pm), a User Contributed Perl Documentation page, and it's literally the Perl extension for VERS (Version Range Specifier). no cap. it's giving "I contain multitudes" but for version numbers β¨
π NAME π
URI::VersionRange β Perl extension for VERS (Version Range Specifier) π
β¨ SYNOPSIS β¨
okay so first you pull it in, then it's giving full OO main character energy:
use URI::VersionRange;
# OO-interface
$vers = URI::VersionRange->new(
scheme => 'cpan',
constraints => ['>2.00']
);
say $vers; # vers:cpan/>2.00
if ($vers->contains('2.10')) {
say "The version is in range";
}
# Parse "vers" string
$vers = URI::VersionRange->from_string('vers:cpan/>2.00|<2.25');
# exported functions
$vers = decode_vers('vers:cpan/>2.00|<2.25');
say $vers->scheme; # cpan
$vers_string = encode_vers(scheme => cpan, constraints => ['>2.00']);
say $vers_string; # vers:cpan/>2.00
# alias
$vers = VERS->new(
scheme => 'cpan',
constraints => ['>2.00']
);
$vers = VERS->from_string('vers:cpan/>2.00|<2.25');
π¦ DESCRIPTION π¦
A version range specifier (VERS) is a URI string using the "vers" URI-scheme with this syntax:
vers:<versioning-scheme>/<version-constraint>|<version-constraint>|...
"vers" is the URI-scheme and is an acronym for "VErsion Range Specifier". so cute, so efficient, obsessed π
The pipe "|" is used as a simple separator between "version-constraint". Each "version-constraint" in this pipe-separated list contains a comparator and a version:
<comparator:version>
This list of "version-constraint" are signposts in the version timeline of a package that specify version intervals. think of them like little neon signs on the highway of version history π£οΈβ¨
A "version" satisfies a version range specifier if it is contained within any of the intervals defined by these "version-constraint".
<https://github.com/package-url/vers-spec>
TC54 - Software and system transparency <https://tc54.org/>
πΈ FUNCTIONAL INTERFACE πΈ
They are exported by default:
encode_vers
$vers_string = encode_vers(%params);
Converts the given "vers" components to "vers" string. Croaks on error. like, it WILL yell at you, fr fr π
This function call is functionally identical to:
$vers_string = URI::VersionRange->new(%params)->to_string;
decode_vers
$vers = decode_vers($vers_string);
Converts the given "vers" string to URI::VersionRange object. Croaks on error. same energy, also yells π
This function call is functionally identical to:
$vers = URI::VersionRange->from_string($vers_string);
π OBJECT-ORIENTED INTERFACE π
new
$vers = URI::VersionRange->new( scheme => STRING, constraints => ARRAY )
$vers = VERS->new( scheme => STRING, constraints => ARRAY )
Create new URI::VersionRange instance using provided VERS components (scheme, constraints). fresh object, fresh vibe π
scheme
$vers->scheme
By convention the versioning scheme should be the same as the URI::PackageURL package "type" for a given package ecosystem.
constraints
$vers->constraints
"constraints" is ARRAY of URI::VersionRange::Constraint object. yes bestie, an ARRAY, plural, multiple little constraint babies π«Ά
contains
$vers->contains($version)
Check if a version is contained within a range
my $vers = URI::VersionRange::from_string('vers:cpan/>2.00|<2.25');
if ($vers->contains('2.10')) {
say "The version is in range";
}
See URI::VersionRange::Version.
constraint_contains
$vers->constraint_contains
Check if a version is contained within a specific constraint.
See URI::VersionRange::Version.
to_hash
$vers->to_hash
Turn VERS components into a hash reference. slay π
to_string
$vers->to_string
Stringify VERS components.
TO_JSON
$vers->TO_JSON
Helper method for JSON modules (JSON, JSON::PP, JSON::XS, Mojo::JSON, etc).
use Mojo::JSON qw(encode_json);
say encode_json($vers);
# {
# "constraints": [
# {
# "comparator": ">",
# "version": "2.00"
# },
# {
# "comparator": "<",
# "version": "2.25"
# }
# ],
# "scheme": "cpan"
# }
from_string
$vers = URI::VersionRange->from_string($vers_string);
$vers = VERS->from_string($vers_string);
Converts the given "vers" string to VERS components and return URI::VersionRange instance. Croaks on error.
from_native
Converts the specified native range string using "native_range_to_vers" and returns and return URI::VersionRange instance.
$vers = URI::VersionRange->from_native('npm', '~1.6.5 || >=1.7.2');
Supported native range scheme:
- conan
- gem
- nginx
- npm
- nuget
- raku
- semver
For other schemes, "native_range_to_vers" will attempt to convert the native range string to a VERS string, but this may not work perfectly.
β οΈ okay so real talk: that last bit is a may not work perfectly situation. it's not a guarantee, it's a vibe attempt. don't come for it π
π 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. bestie they will literally ping you, that's so thoughtful ππ«Ά
π¦ 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
β 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.
and that's the whole page, periodt π
this was URI::VersionRange, part of the User Contributed Perl Documentation, brought to you by perl v5.40.1 on 2026-01-31. go forth and range your versions, icon πβ¨
π¦ 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