UUID (3)
Leading comments
Automatically generated by Pod::Man 4.09 (Pod::Simple 3.35) Standard preamble: ========================================================================
NAME
UUID - DCE compatible Universally Unique Identifier library for PerlSYNOPSIS
use UUID ':all'; generate($uuid); # generate binary UUID, prefer random generate_random($uuid); # generate binary UUID, using random generate_time($uuid); # generate binary UUID, using time $string = uuid(); # generate stringified UUID unparse($uuid, $string); # change $uuid string unparse_lower($uuid, $string); # change $uuid to lowercase string unparse_upper($uuid, $string); # change $uuid to uppercase string $rc = parse($string, $uuid); # map string to UUID, return -1 on error copy($dst, $src); # copy binary UUID from $src to $dst compare($uuid1, $uuid2); # compare binary UUIDs clear( $uuid ); # set binary UUID to NULL is_null( $uuid); # compare binary UUID to NULL
DESCRIPTION
TheThe 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 (
FUNCTIONS
Most of theNot very Perlish, is it? It's been like that for a long time though, so not very likely to change any time soon.
All take or return UUIDs in either binary or string format. The string format resembles the following:
1b4e28ba-2fa1-11d2-883f-0016d3cca427
Or, in terms of printf(3) format:
"%08x-%04x-%04x-%04x-%012x"
The binary format is simply a packed 16 byte binary value.
generate( $uuid )
Generates a new binaryAlternately, the current time, the local ethernet
The previous content of $uuid, if any, is lost.
generate_random( $uuid )
Generates a new binaryNote that the use of a pseudo-random generator may compromise the uniqueness of UUIDs generated in this fashion.
generate_time( $uuid )
Generates a new binaryThis algorithm used to be the default one used to generate UUIDs, but because of the use of the ethernet
This can cause privacy problems in some applications, so the generate() function only uses this algorithm if a high-quality source of randomness is not available.
unparse( $uuid, $string )
Converts the binaryThe case of the hex digits returned may be upper or lower case, and is dependent on the system-dependent local default.
unparse_lower( $uuid, $string )
Same as unparse() but $string is forced to lower case.unparse_upper( $uuid, $string )
Same as unparse() but $string is forced to upper case.$rc = parse( $string, $uuid )
Converts the string formatReturns 0 on success and -1 on failure. Additionally on failure, the content of $uuid is unchanged.
clear( $uuid )
Sets $uuid equal to the value of theis_null( $uuid )
Compares the value of $uuid to theReturns 1 if
copy( $dst, $src )
Copies the binary $srcIf $src isn't a
compare( $uuid1, $uuid2 )
Compares two binary UUIDs.Returns an integer less than, equal to, or greater than zero if $uuid1 is less than, equal to, or greater than $uuid2.
However, if either operand is not a
$string = uuid()
Creates a new string formatFunctionally the equivalent of calling generate() and then unparse(), but throwing away the intermediate binary
EXPORTS
All functions may be imported in the usual manner, either individually or all at once using the ":all" tag.TODO
Need more tests and sanity checks.COPYRIGHT AND LICENSE
This software is Copyright (c) 2014, 2015 by Rick Myers.This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)
Details of this license can be found within the 'License' text file.
AUTHOR
Current maintainer:
Rick Myers <jrm@cpan.org>.
Authors and/or previous maintainers:
Lukas Zapletal <lzap@cpan.org> Joseph N. Hall <joseph.nathan.hall@gmail.com> Colin Faber <cfaber@clusterfs.com> Peter J. Braam <braam@mountainviewdata.com>