| Test2::Util::UUID(3pm) | User Contributed Perl Documentation | Test2::Util::UUID(3pm) |
Test2::Util::UUID - Utils for generating UUIDs under Test2.
This module provides a consistent UUID source for all of Test2.
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);
One of the following modules will be used under the hood, they are listed here in order of preference.
A warning will be issued with this module. You can surpress the warning with either the $TEST2_UUID_NO_WARN environment variable or the "warn => 0" import argument.
A warning will be issued with this module. You can surpress the warning with either the $TEST2_UUID_NO_WARN environment variable or the "warn => 0" import argument.
AT IMPORT
use Test2::Util::UUID 'gen_uuid', warn => 0;
Passing in "warn => 0" will disable the warnings normally issued when using UUID::Tiny or Data::UUID as a backend.
AT IMPORT
If you wish to override the order and specify which backend to use you may do so by listing them during import prefixed with ':'.
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.
Note: You must include these import arguments anywhere you import this module, otherwise the other imports will use the default list, resulting in different places using different UUIDs.
THE $TEST2_UUID_BACKEND ENV VAR
Setting the $TEST2_UUID_BACKEND env var to one of the backends, or a comma seperated list will override the default list for all imports. It will NOT override imports that specify their own lists.
Returns the input value if it looks like a UUID, otherise it returns undef.
The source code repository for Test2-Plugin-UUID can be found at https://github.com/Test-More/Test2-Plugin-UUID/.
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/
| 2025-03-31 | perl v5.40.1 |