NAME

UUID::V7 - A precise UUIDv7 implementation

VERSION

version 0.002

SYNOPSIS

use UUID::V7 ':all';

my $uuid = generate_uuid_v7();
my $time = extract_uuid_v7_time($uuid);

my binary = uuid_string_to_binary($uuid);
my $uuid = uuid_binary_to_string($binary);
croak "Not UUIDv7" unless is_uuid_v7($uuid);

DESCRIPTION

UUID version 7 are monotonically ascending and creation-time ordered unique identifiers, making them particularly suitable for database indices.

FUNCTIONS

generate_uuid_v7

my $uuid = generate_uuid_v7();

This will generate a new UUIDv7 identifier. This will use 60 bits of timing information (±250 nanoseconds) for monotonicity with high-frequency UUID generation if available on your platform. It will contain 62 bits of cryptographically strong randomness.

extract_uuid_v7_time

my $time = extract_uuid_v7_time($uuid);

This will extract the time out of a UUIDv7.

uuid_string_to_binary

my $binary = uuid_string_to_binary($uuid);

This will convert a UUID string to its equivalent 16-byte big-endian binary value.

uuid_binary_to_string

my $uuid = uuid_binary_to_string($binary);

This will convert a 16-byte big-endian binary value to its equivalent UUID string.

is_uuid_v7

my $is_7 = is_uuid_v7($uuid);

This returns true if the UUID is version 7

SEE ALSO

For UUIDv4, Crypt::SysRandom provides a random_uuid function.

AUTHOR

Leon Timmermans <fawaka@gmail.com>

COPYRIGHT AND LICENSE

This software is copyright (c) 2026 by Leon Timmermans.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.