Version::Util(3pm)

๐Ÿ“ฆ
version 0.732 ยท 3 versions
, in ubuntu noble, ubuntu resolute, ubuntu stonking

โœจ 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 ๐Ÿ˜ค


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