Data::...LibUUID(3pm)
π Data::...LibUUID β the whole vibe
okay so bestie, welcome to Data::...LibUUID (that's the Data::UUID::LibUUID page from User Contributed Perl Documentation, iykyk) π
This is the module for making UUIDs by just... calling into the uuid.h that's already on your system. Depending on your platform you're getting version 2 or version 4, which is lowkey the whole personality of this thing.
β¨ SYNOPSIS β¨
Look how short this is. Obsessed. π
use Data::UUID::LibUUID;
my $uuid = new_uuid_string();
πΈ DESCRIPTION πΈ
So what's happening under the hood? This module gives you bindings for libuuid, the one that ships with e2fsprogs, or with uuid-dev if you're on Debian. And on darwin it plays nice with the system uuid.h too. Cross-platform slay. π
π¦ EXPORTS π¦
Here's everything you get, one at a time, no skipping. π
new_uuid_string $versionnew_uuid_binary $version
These give you a brand new UUID β either in string format (dash separated hex) or binary format (16 octets). Both formats, both iconic.
$version can be either 2 or 4, and it defaults to whatever the underlying implementation prefers. (So like, it has a favourite, and you're letting it choose. Respect. π)
Fair warning though: version 1 is timestamp/MAC based UUIDs, same energy as what Data::UUID provides. They literally reveal time and host information, so they may be considered a security risk. Not the move, bestie. π₯
Version 2 is described here: <http://www.opengroup.org/onlinepubs/9696989899/chap5.htm#tagcjh_08_02_01_01>. It's similar to version 1 but considered more secure. Glow up fr fr. β¨
Version 4 is based just on random data. This is not guaranteed to be high quality random data, but usually is supposed to be. π
On MacOS X, getpid is called before UUID generation, to ensure UUIDs are unique accross forks. Behavior on other platforms may vary.
uuid_to_binary $str_or_bin
Converts a UUID from string or binary format to binary format.
Returns undef on a non UUID argument.
uuid_to_string $str_or_bin
Converts a UUID from string or binary format to string format.
Returns undef on a non UUID argument.
uuid_eq $str_or_bin, $str_or_bin
Checks if two UUIDs are equivalent. Returns true if they are, or false if they aren't. The classic "are we the same tho" check. π«Ά
Returns undef on non UUID arguments.
uuid_compare $str_or_bin, $str_or_bin
Returns -1, 0 or 1 depending on the lexicographical order of the UUID. This works like the cmp builtin.
Returns undef on non UUID arguments.
new_dce_uuid_stringnew_dce_uuid_binary
These two subroutines are a little hackish in that they take no arguments but also do not validate the arguments, so they can be abused as methods. Not me saying "abused" like that π but here's the tea:
package MyFoo;
use Data::UUID::LibUUID (
new_dce_uuid_string => { -as "generate_uuid" },
);
sub yadda {
my $self = shift;
my $id = $self->generate_uuid;
}
This allows the ID generation code to be subclassed, but still keeps the hassle down to a minimum. DCE is the UUID version two specification. So you get the power and the convenience. Main character energy, honestly. π
ascending_ident
Creates a lexically ascending identifier containing a UUID, high resolution timestamp, and a counter. Three ingredients, one identifier. π
Heads up: this is not a UUID (it's longer), but if you can store variable length identifier (and exposing the system clock is not an issue) they can be used to create an identifier that is both universally unique, and lexically increasing.
Note that while the identifiers are universally unique, there is no universal ordering (that would require synchronization), so identifiers generated on different machines or even different process/thread could have IDs which interleave. Interleaving?! π It's giving chaos, but in a mathematically valid way.
π TODO π
- Consider bundling
libuuidfor when no systemuuid.hexists.
β SEE ALSO β
Go check out the whole friend group:
Data::GUIDData::UUIDUUID- <http://e2fsprogs.sourceforge.net/>
π§ VERSION CONTROL π§
This module is maintained using Darcs. Yes, Darcs. You can get the latest version from <http://nothingmuch.woobling.org/code>, and use darcs send to commit changes.
π AUTHOR π
Yuval Kogman <nothingmuch@woobling.org>
π COPYRIGHT π
Copyright (c) 2008 Yuval Kogman. All rights reserved
This program is free software; you can redistribute
it and/or modify it under the same terms as Perl itself.
okay that's the whole page bestie, go forth and generate some UUIDs πβ¨
perl v5.42.3 Β· 2026-08-19 Β· and yes, the manual is literally named Data::...LibUUID(3pm) β the ellipsis is in the name, we don't make the rules, we just slay by them π
π¦
π¦ where this page comes from
- ubuntu stonking: libdata-uuid-libuuid-perl 0.05-6build4 Β· 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