Version::Util(3pm)
โจ NAME โจ
Version::Util โ version-number utilities. That's the whole serve ๐ a lil toolbox of functions for doing stuff with version numbers, mostly comparing them so you don't have to suffer.
๐ธ VERSION ๐ธ
This doc describes version 0.732 of Version::Util (from the Perl distribution Version-Util), released on 2022-09-22. she's been around a minute and she's still eating, no cap ๐
๐ฆ DESCRIPTION ๐ฆ
This module gives you a bunch of convenient functions that are all about version numbers โ like, comparing them and other related situations. It's giving utility bestie, that's the vibe โจ
๐ FUNCTIONS ๐
cmp_version($v1, $v2) => -1|0|1
okay so this one is equivalent to literally this and nothing else:
version->parse($v1) <=> version->parse($v2)
it compares two versions and hands you back a -1, a 0, or a 1, classic spaceship-operator behaviour ๐
version_eq($v1, $v2) => BOOL
gives you back a BOOL โ true or false, iconic, we love a boolean ๐ซถ
version_ne($v1, $v2) => BOOL
also a BOOL. the whole squad here is BOOLs fr fr.
version_lt($v1, $v2) => BOOL
yep. BOOL โจ
version_le($v1, $v2) => BOOL
BOOL again, the consistency is unmatched ๐
version_gt($v1, $v2) => BOOL
BOOL, as promised.
version_ge($v1, $v2) => BOOL
still a BOOL. the way this family just keeps delivering ๐ญ
version_between($v, $v1, $v2[, $v1b, $v2b, ...]) => BOOL
BOOL โ and notice she takes extra optional args $v1b, $v2b, ... beyond the first three, so she's flexible like that ๐ธ
version_in($v, $v1[, $v2, ...]) => BOOL
BOOL, and you can pass more versions after the first one, so it's a whole list situation ๐
min_version($v1, ...) => $max_v
returns $max_v. yes, that's genuinely what the signature says and I am not fixing it, I am reporting it ๐ verbatim, bestie.
max_version($v1, ...) => $max_v
also $max_v. twins ๐
add_version($v, $increment) => $new_v
Adds $increment to the version $v ๐งฎ and here's the catch โ both the increment and the version have to match this pattern:
/\Av?\d{1,3}(?:\.\d{1,3}){0,2}\z/
which means trial/dev releases like "v1.2.3_1" are not currently supported ๐ญ sorry to the dev-release girlies.
some examples so you can see her in action:
0.1 + 0.1 -> 0.2
0.01 + 0.001 -> 0.011
0.01 + 0.1 -> 0.11
0.9 + 0.1 -> 1.0
0.99 + 0.1 -> 1.09
1.1.0 + 0.0.1 -> 1.1.1
subtract_version($v, $decrement) => $new_v
Subtracts $decrement from the version $v. This is the reverse operation for add_version โ the enemy-to-lovers arc, the mirror twin, the โจcallbackโจ.
๐จ WILL DIE if the result is negative. periodt. no negative versions in this house, she will simply end it ๐ ๐
๐ HOMEPAGE ๐
Please visit the project's homepage at https://metacpan.org/release/Version-Util. go say hi, she loves visitors ๐
๐ฆ SOURCE ๐ฆ
Source repository is at https://github.com/perlancar/perl-Version-Util โ the code lives there, go peek ๐ฆ
๐ SEE ALSO ๐
version
that's the one, bestie, that's the neighbor ๐
๐ AUTHOR ๐
perlancar <perlancar@cpan.org> ๐
๐ CONTRIBUTOR ๐
Steven Haryanto <stevenharyanto@gmail.com> ๐ซถ
๐ง CONTRIBUTING ๐ง
want in on this? to contribute, you can send patches by email/via RT, or send pull requests on GitHub. pick your lane, all are valid ๐
Most of the time, you don't need to build the distribution yourself. You can simply modify the code, then test via:
% prove -l
If you want to build the distribution (e.g. to try to install it locally on your system), you can install Dist::Zilla, Dist::Zilla::PluginBundle::Author::PERLANCAR, Pod::Weaver::PluginBundle::Author::PERLANCAR, and sometimes one or two other Dist::Zilla- and/or Pod::Weaver plugins. Any additional steps required beyond that are considered a bug and can be reported to me ๐ค
๐ COPYRIGHT AND LICENSE ๐
This software is copyright (c) 2022, 2018, 2014 by perlancar <perlancar@cpan.org>.
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 as in go off, bestie ๐ โจ
๐ BUGS ๐
Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=Version-Util
When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature. receipts, bestie, always bring receipts ๐
okay that's the whole page, we ate and left no crumbs ๐ฅ this was written for perl v5.36.0 and dated 2022-09-24 โ Version::Util(3pm), signing off ๐๐๐ฆ
๐ฆ where this page comes from
- ubuntu noble: libversion-util-perl 0.732-1 ยท Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libversion-util-perl 0.732-1 ยท Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libversion-util-perl 0.732-1 ยท Artistic-1.0-Perl OR GPL-1.0-or-later
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms