.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "UUID 3pm" .TH UUID 3pm 2024-01-10 "perl v5.38.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME UUID \- DCE compatible Universally Unique Identifier library for Perl .SH SYNOPSIS .IX Header "SYNOPSIS" .Vb 1 \& use UUID \*(Aquuid\*(Aq; \& \& $string = uuid(); # generate stringified UUID \& \& UUID::generate($uuid); # new binary UUID; prefer random \& UUID::generate_random($uuid); # new binary UUID; use random \& UUID::generate_time($uuid); # new binary UUID; use time \& \& UUID::unparse($uuid, $string); # stringify $uuid; system casing \& UUID::unparse_lower($uuid, $string); # force lowercase stringify \& UUID::unparse_upper($uuid, $string); # force uppercase stringify \& \& $rc = UUID::parse($string, $uuid); # map string to UUID; \-1 on error \& \& UUID::copy($dst, $src); # copy binary UUID from $src to $dst \& UUID::compare($uuid1, $uuid2); # compare binary UUIDs \& \& UUID::clear( $uuid ); # set binary UUID to NULL \& UUID::is_null( $uuid ); # compare binary UUID to NULL .Ve .SH DESCRIPTION .IX Header "DESCRIPTION" The UUID library is used to generate unique identifiers for objects that may be accessible beyond the local system. For instance, they could be used to generate unique HTTP cookies across multiple web servers without communication between the servers, and without fear of a name clash. .PP The generated UUIDs can be reasonably expected to be unique within a system, and unique across all systems, and are compatible with those created by the Open Software Foundation (OSF) Distributed Computing Environment (DCE) utility uuidgen. .SH FUNCTIONS .IX Header "FUNCTIONS" Most of the UUID functions expose the underlying \fIlibuuid\fR C interface rather directly. That is, many return their values in their parameters and nothing else. .PP Not very Perlish, is it? It's been like that for a long time though, so not very likely to change any time soon. .PP All take or return UUIDs in either binary or string format. The string format resembles the following: .PP .Vb 1 \& 1b4e28ba\-2fa1\-11d2\-883f\-0016d3cca427 .Ve .PP Or, in terms of \fBprintf\fR\|(3) format: .PP .Vb 1 \& "%08x\-%04x\-%04x\-%04x\-%012x" .Ve .PP The binary format is simply a packed 16 byte binary value. .ie n .SS "\fBgenerate(\fP \fI\fP\fI$uuid\fP\fI\fP \fB)\fP" .el .SS "\fBgenerate(\fP \fI\fP\f(CI$uuid\fP\fI\fP \fB)\fP" .IX Subsection "generate( $uuid )" Generates a new binary UUID based on high quality randomness from \&\fI/dev/urandom\fR, if available. .PP Alternately, the current time, the local ethernet MAC address (if available), and random data generated using a pseudo-random generator are used. .PP The previous content of \fR\f(CI$uuid\fR\fI\fR, if any, is lost. .ie n .SS "\fBgenerate_random(\fP \fI\fP\fI$uuid\fP\fI\fP \fB)\fP" .el .SS "\fBgenerate_random(\fP \fI\fP\f(CI$uuid\fP\fI\fP \fB)\fP" .IX Subsection "generate_random( $uuid )" Generates a new binary UUID but forces the use of the all-random algorithm, even if a high-quality random number generator (i.e., \&\fI/dev/urandom\fR) is not available, in which case a pseudo-random generator is used. .PP Note that the use of a pseudo-random generator may compromise the uniqueness of UUIDs generated in this fashion. .ie n .SS "\fBgenerate_time(\fP \fI\fP\fI$uuid\fP\fI\fP \fB)\fP" .el .SS "\fBgenerate_time(\fP \fI\fP\f(CI$uuid\fP\fI\fP \fB)\fP" .IX Subsection "generate_time( $uuid )" Generates a new binary UUID but forces the use of the alternative algorithm which uses the current time and the local ethernet MAC address (if available). .PP This algorithm used to be the default one used to generate UUIDs, but because of the use of the ethernet MAC address, it can leak information about when and where the UUID was generated. .PP This can cause privacy problems in some applications, so the \fBgenerate()\fR function only uses this algorithm if a high-quality source of randomness is not available. .ie n .SS "\fBunparse(\fP \fI\fP\fI$uuid\fP\fI\fP\fB,\fP \fI\fP\fI$string\fP\fI\fP \fB)\fP" .el .SS "\fBunparse(\fP \fI\fP\f(CI$uuid\fP\fI\fP\fB,\fP \fI\fP\f(CI$string\fP\fI\fP \fB)\fP" .IX Subsection "unparse( $uuid, $string )" Converts the binary UUID in \fR\f(CI$uuid\fR\fI\fR to string format and returns in \&\fI\fR\f(CI$string\fR\fI\fR. The previous content of \fI\fR\f(CI$string\fR\fI\fR, if any, is lost. .PP The case of the hex digits returned may be upper or lower case, and is dependent on the system-dependent local default. .ie n .SS "\fBunparse_lower(\fP \fI\fP\fI$uuid\fP\fI\fP\fB,\fP \fI\fP\fI$string\fP\fI\fP \fB)\fP" .el .SS "\fBunparse_lower(\fP \fI\fP\f(CI$uuid\fP\fI\fP\fB,\fP \fI\fP\f(CI$string\fP\fI\fP \fB)\fP" .IX Subsection "unparse_lower( $uuid, $string )" Same as \fBunparse()\fR but \fR\f(CI$string\fR\fI\fR is forced to lower case. .ie n .SS "\fBunparse_upper(\fP \fI\fP\fI$uuid\fP\fI\fP\fB,\fP \fI\fP\fI$string\fP\fI\fP \fB)\fP" .el .SS "\fBunparse_upper(\fP \fI\fP\f(CI$uuid\fP\fI\fP\fB,\fP \fI\fP\f(CI$string\fP\fI\fP \fB)\fP" .IX Subsection "unparse_upper( $uuid, $string )" Same as \fBunparse()\fR but \fR\f(CI$string\fR\fI\fR is forced to upper case. .ie n .SS "\fB\fP\fB$rc\fP\fB = parse(\fP \fI\fP\fI$string\fP\fI\fP\fB,\fP \fI\fP\fI$uuid\fP\fI\fP \fB)\fP" .el .SS "\fB\fP\f(CB$rc\fP\fB = parse(\fP \fI\fP\f(CI$string\fP\fI\fP\fB,\fP \fI\fP\f(CI$uuid\fP\fI\fP \fB)\fP" .IX Subsection "$rc = parse( $string, $uuid )" Converts the string format UUID in \fR\f(CI$string\fR\fI\fR to binary and returns in \&\fI\fR\f(CI$uuid\fR\fI\fR. The previous content of \fI\fR\f(CI$uuid\fR\fI\fR, if any, is lost. .PP Returns 0 on success and \-1 on failure. Additionally on failure, the content of \fR\f(CI$uuid\fR\fI\fR is unchanged. .ie n .SS "\fBclear(\fP \fI\fP\fI$uuid\fP\fI\fP \fB)\fP" .el .SS "\fBclear(\fP \fI\fP\f(CI$uuid\fP\fI\fP \fB)\fP" .IX Subsection "clear( $uuid )" Sets \fR\f(CI$uuid\fR\fI\fR equal to the value of the NULL UUID. .ie n .SS "\fBis_null(\fP \fI\fP\fI$uuid\fP\fI\fP \fB)\fP" .el .SS "\fBis_null(\fP \fI\fP\f(CI$uuid\fP\fI\fP \fB)\fP" .IX Subsection "is_null( $uuid )" Compares the value of \fR\f(CI$uuid\fR\fI\fR to the NULL UUID. .PP Returns 1 if NULL, and 0 otherwise. .ie n .SS "\fBcopy(\fP \fI\fP\fI$dst\fP\fI\fP\fB,\fP \fI\fP\fI$src\fP\fI\fP \fB)\fP" .el .SS "\fBcopy(\fP \fI\fP\f(CI$dst\fP\fI\fP\fB,\fP \fI\fP\f(CI$src\fP\fI\fP \fB)\fP" .IX Subsection "copy( $dst, $src )" Copies the binary \fR\f(CI$src\fR\fI\fR UUID to \fI\fR\f(CI$dst\fR\fI\fR. .PP If \fR\f(CI$src\fR\fI\fR isn't a UUID, \fI\fR\f(CI$dst\fR\fI\fR is set to the NULL UUID. .ie n .SS "\fBcompare(\fP \fI\fP\fI$uuid1\fP\fI\fP\fB,\fP \fI\fP\fI$uuid2\fP\fI\fP \fB)\fP" .el .SS "\fBcompare(\fP \fI\fP\f(CI$uuid1\fP\fI\fP\fB,\fP \fI\fP\f(CI$uuid2\fP\fI\fP \fB)\fP" .IX Subsection "compare( $uuid1, $uuid2 )" Compares two binary UUIDs. .PP Returns an integer less than, equal to, or greater than zero if \&\fR\f(CI$uuid1\fR\fI\fR is less than, equal to, or greater than \fI\fR\f(CI$uuid2\fR\fI\fR. .PP However, if either operand is not a UUID, falls back to a simple string comparison returning similar values. .ie n .SS "\fB\fP\fI\fP\fI$string\fP\fI\fP \fB= uuid()\fP" .el .SS "\fB\fP\fI\fP\f(CI$string\fP\fI\fP \fB= uuid()\fP" .IX Subsection "$string = uuid()" Creates a new string format UUID and returns it in a more Perlish way. .PP Functionally the equivalent of calling \fBgenerate()\fR and then \fBunparse()\fR, but throwing away the intermediate binary UUID. .SH "UUID LIBRARY" .IX Header "UUID LIBRARY" On some systems external packages will need to be installed first. Notably, uuid-dev, libuuid-devel, or uuid-devel, depending on your platform. .PP Some may also have more than one package available. It should be safe to install all variations. The UUID installer will then opt towards the older, faster library. .SH EXPORTS .IX Header "EXPORTS" None by default. All functions may be imported in the usual manner, either individually or all at once using the "\fI:all\fR" tag. .SH TODO .IX Header "TODO" Need more tests and sanity checks. .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" This software is Copyright (c) 2014\-2023 by Rick Myers. .PP This is free software, licensed under: .PP .Vb 1 \& The Artistic License 2.0 (GPL Compatible) .Ve .PP Details of this license can be found within the 'LICENSE' text file. .SH AUTHOR .IX Header "AUTHOR" Current maintainer: .PP .Vb 1 \& Rick Myers . .Ve .PP Authors and/or previous maintainers: .PP .Vb 1 \& Lukas Zapletal \& \& Joseph N. Hall \& \& Colin Faber \& \& Peter J. Braam .Ve .SH CONTRIBUTORS .IX Header "CONTRIBUTORS" David E. Wheeler .PP William Faulk .PP gregor herrmann .PP Slaven Rezic .PP twata .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fBuuid\|(3)\fR, \fBuuid_clear\|(3)\fR, \fBuuid_compare\|(3)\fR, \fBuuid_copy\|(3)\fR, \&\fBuuid_generate\|(3)\fR, \fBuuid_is_null\|(3)\fR, \fBuuid_parse\|(3)\fR, \&\fBuuid_unparse\|(3)\fR, \fBperl\|(1)\fR.