Test2:...l::UUID(3pm)
π Test2::Util::UUID π
okay bestie, so this is a page from the User Contributed Perl Documentation for the module Test2::Util::UUID, and it's literally just the UUID factory for the whole Test2 universe π¦
β¨ NAME β¨
Test2::Util::UUID β utils for generating UUIDs under Test2. that's it, that's the whole job, and she does it flawlessly π
πΈ DESCRIPTION πΈ
This module is the one-stop glow-up spot for UUIDs across all of Test2. Like, every part of Test2 that needs a UUID gets it from here, so everybody's on the same page. consistent queen energy π
π SYNOPSIS π
use Test2::Util::UUID qw/gen_uuid looks_like_uuid uuid2bin bin2uuid/;
my $uuid = gen_uuid;
my $bin = bin2uuid($uuid);
my $uuid_again = uuid2bin($uuid);
no cap, that's the whole vibe β¨
π₯ UNDER THE HOOD π₯
So here's the tea π β this module doesn't do the UUID-making all by herself. She picks a helper module, and the candidates are listed in order of preference, most-favored first.
UUID >= 0.35β when it's possible, she'll use theUUIDcpan module. BUT π¨ it has to be version0.35or greater, because anything older has a fork-related bug and we do not do bugs in this house. This one generates version 7 UUIDs, because those are the most suitable for database entry. iconic behavior fr fr πData::UUID::MTβ the second choice for UUID generation. With this one you get version 4 UUIDs, which are fairly usable in databases. solid, dependable, no notes π«ΆUUID::Tiny- slow β used only if the previous two aren't available. This module is pure perl, so it could be slower than the others π. Version 4 UUIDs get generated when this one is used. Also, a warning will be issued with this module. You can suppress that warning with either the$TEST2_UUID_NO_WARNenvironment variable or the"warn => 0"import argument.Data::UUID- Not Suitable for Databases β this is the last resort, bestie, we're scraping the bottom of the barrel π. It generates UUIDs fast, but they're of a type/version that is not suitable for database keys. A warning will be issued with this module too, and you can suppress it with either the$TEST2_UUID_NO_WARNenvironment variable or the"warn => 0"import argument.
CONTROLLING WARNINGS
AT IMPORT
use Test2::Util::UUID 'gen_uuid', warn => 0;
Passing in "warn => 0" will disable the warnings that normally get issued when using UUID::Tiny or Data::UUID as a backend. peace and quiet, periodt π€«
SELECTING A BACKEND
AT IMPORT
If you want to override the order and pick exactly which backend gets used, you can do that by listing them during import, each one prefixed with a ':'. watch this β¨
use Test2::Util::UUID 'gen_uuid', backends => [':UUID', ':UUID::Tiny'];
The above will try the UUID module first, followed by the UUID::Tiny module. It will not try Data::UUID::MT or Data::UUID. main character choices only π
Note: you must include these import arguments anywhere you import this module, otherwise the other imports will use the default list, which results in different places using different UUIDs π. keep it consistent, bestie.
THE $TEST2_UUID_BACKEND ENV VAR
Setting the $TEST2_UUID_BACKEND env var to one of the backends β or a comma separated list β will override the default list for all imports. It will NOT override imports that specify their own lists though. she respects a girl who makes her own choices π
π¦ EXPORTS π¦
$uuid = gen_uuid()β generates a UUID, and it's always normalized to upper case. uppercase only, we don't do lowercase here π$uuid_or_undef = looks_like_uuid($UUID)β checks if the value you handed over actually looks like a UUID. It makes sure it is defined, 36 characters long, has dashes, and only contains0-9,a-fand dash (case insensitive). Returns the input value if it looks like a UUID, otherwise it returnsundef. vibe check passed or failed, no in-between β¨
π SOURCE π
The source code repository for Test2-Plugin-UUID can be found at https://github.com/Test-More/Test2-Plugin-UUID/. go peek, bestie, the code is right there π«Ά
π MAINTAINERS π
- Chad Granum <exodist@cpan.org>
π AUTHORS π
- Chad Granum <exodist@cpan.org>
πΈ COPYRIGHT πΈ
Copyright Chad Granum <exodist@cpan.org>.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
See http://dev.perl.org/licenses/
okay and that's a wrap π this page came from the perl manual, version v5.40.1, dated 2025-03-31, and honestly? she ate. go generate some UUIDs, you've got this πβ¨π¦
π¦ where this page comes from
- debian trixie: libtest2-plugin-uuid-perl 0.002010-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libtest2-plugin-uuid-perl 0.002010-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libtest2-plugin-uuid-perl 0.002010-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