UUID(3)
okay bestie, welcome to UUID(3) β the manual name is literally right there β brought to you by the User Contributed Perl Documentation crew πβ¨
π NAME π
Data::UUID β Globally/Universally Unique Identifiers (GUIDs/UUIDs) π
π¦ SEE INSTEAD? π¦
So there's another module, Data::GUID, that gives you another interface for generating GUIDs. RN it relies on Data::UUID, but it may not in the future. Its interface may be just a little more straightforward for the average Perl programmer. iykyk π«Ά
β¨ SYNOPSIS β¨
use Data::UUID;
$ug = Data::UUID->new;
$uuid1 = $ug->create();
$uuid2 = $ug->create_from_name(<namespace>, <name>);
$res = $ug->compare($uuid1, $uuid2);
$str = $ug->to_string( $uuid );
$uuid = $ug->from_string( $str );
πΈ DESCRIPTION πΈ
This module gives you a whole framework for making v3 UUIDs (Universally Unique Identifiers, also known as GUIDs β Globally Unique Identifiers). A UUID is 128 bits long, and it's guaranteed to be different from all other UUIDs/GUIDs generated until 3400 CE. periodt β
UUIDs were originally used in the Network Computing System (NCS) and later in the Open Software Foundation's (OSF) Distributed Computing Environment. Currently lots of different technologies rely on UUIDs to give unique identity to various software components. Microsoft COM/DCOM, for instance, uses GUIDs very extensively to uniquely identify classes, applications and components across network-connected systems. slay π
The algorithm for UUID generation, used by this extension, is described in the Internet Draft "UUIDs and GUIDs" by Paul J. Leach and Rich Salz. (See RFC 4122.) It provides a reasonably efficient and reliable framework for generating UUIDs and supports fairly high allocation rates β 10 million per second per machine β and therefore is suitable for identifying both extremely short-lived and very persistent objects on a given system as well as across the network. no cap π¦
This module provides several methods to create a UUID. In all methods, <namespace> is a UUID and <name> is a free form string. ok so here's the whole menu, bestie:
# creates binary (16 byte long binary value) UUID.
$ug->create();
$ug->create_bin();
# creates binary (16-byte long binary value) UUID based on particular
# namespace and name string.
$ug->create_from_name(<namespace>, <name>);
$ug->create_from_name_bin(<namespace>, <name>);
# creates UUID string, using conventional UUID string format,
# such as: 4162F712-1DD2-11B2-B17E-C09EFE1DC403
# Note that digits A-F are capitalized, which is contrary to rfc4122
$ug->create_str();
$ug->create_from_name_str(<namespace>, <name>);
# creates UUID string as a hex string,
# such as: 0x4162F7121DD211B2B17EC09EFE1DC403
# Note that digits A-F are capitalized, which is contrary to rfc4122
$ug->create_hex();
$ug->create_from_name_hex(<namespace>, <name>);
# creates UUID string as a Base64-encoded string
$ug->create_b64();
$ug->create_from_name_b64(<namespace>, <name>);
Binary UUIDs can be converted to printable strings using following methods:
# convert to conventional string representation
$ug->to_string(<uuid>);
# convert to hex string (using upper, rather than lower, case letters)
$ug->to_hexstring(<uuid>);
# convert to Base64-encoded string
$ug->to_b64string(<uuid>);
Conversely, string UUIDs can be converted back to binary form:
# recreate binary UUID from string
$ug->from_string(<uuid>);
$ug->from_hexstring(<uuid>);
# recreate binary UUID from Base64-encoded string
$ug->from_b64string(<uuid>);
Finally, two binary UUIDs can be compared using the following method:
# returns -1, 0 or 1 depending on whether uuid1 less
# than, equals to, or greater than uuid2
$ug->compare(<uuid1>, <uuid2>);
Examples:
use Data::UUID;
# this creates a new UUID in string form, based on the standard namespace
# UUID NameSpace_URL and name "www.mycompany.com"
$ug = Data::UUID->new;
print $ug->create_from_name_str(NameSpace_URL, "www.mycompany.com");
π EXPORT π
The module allows exporting of several standard namespace UUIDs:
NameSpace_DNSNameSpace_URLNameSpace_OIDNameSpace_X500
π AUTHOR π
Alexander Golomshtok <agolomsh@cpan.org> β iconic behavior, honestly π
π SEE ALSO π
The Internet Draft "UUIDs and GUIDs" by Paul J. Leach and Rich Salz (RFC 4122) β go read it, bestie, it's giving lore π₯
okay bye bestie π«Ά this page is from perl v5.40.2, dated 2024-06-10, and yes it's the UUID(3) page ofc π
β¨
π¦ where this page comes from
- alpine 3.22: perl-data-uuid-doc 1.227-r1 Β· osf-1990(variant)
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms