This module provides the NIL UUID (shown with its string representation):
|<B>Pre-defined Namespace UUIDsB>||
This module provides the common pre-defined namespace UUIDs (shown with their
This module provides the UUID version numbers as constants:
With use UUID::Tiny :std; you get additional, speaking constants:
my $uuid = create_UUID( UUID_SHA1_AVAIL? UUID_V5 : UUID_V3, $str );
UUID::Tiny (since version 1.02) tries to load Digest::SHA, Digest::SHA1 or Digest::SHA::PurePerl, but does not die if none of them is found. Instead create_UUID() and create_UUID_as_string() die when trying to create an SHA-1 based UUID without an appropriate module available.
All public functions are exported by default (they should not collide with other functions).
create_UUID() creates standard binary UUIDs in network byte order (MSB first), create_UUID_as_string() creates the standard string representation of UUIDs.
All query and test functions (except is_UUID_string) accept both representations.
<B>B>create_UUID()<B>B>, <B>B>create_uuid()<B>B> (:std) my $v1_mc_UUID = create_UUID(); my $v1_mc_UUID = create_UUID(UUID_V1); my $v3_md5_UUID = create_UUID(UUID_V3, $ns_uuid, $name_or_filehandle); my $v3_md5_UUID = create_UUID(UUID_V3, $name_or_filehandle); my $v4_rand_UUID = create_UUID(UUID_V4); my $v5_sha1_UUID = create_UUID(UUID_V5, $ns_uuid, $name_or_filehandle); my $v5_sha1_UUID = create_UUID(UUID_V5, $name_or_filehandle);
Creates a binary UUID in network byte order (MSB first). For v3 and v5 UUIDs a SCALAR (normally a string), GLOB (classic file handle) or IO object (i.e. IO::File) can be used; files have to be opened for reading.
I found no hint if and how UUIDs should be created from file content. It seems to be undefined, but it is useful - so I would suggest to use UUID_NIL as the namespace UUID, because no real name is used; UUID_NIL is used by default if a namespace UUID is missing (only 2 arguments are used).
<B>B>create_UUID_as_string()<B>B>, <B>B>create_uuid_as_string()<B>B> (:std) Similar to create_UUID, but creates a UUID string. <B>B>is_UUID_string()<B>B>, <B>B>is_uuid_string()<B>B> (:std) my $bool = is_UUID_string($str); <B>B>UUID_to_string()<B>B>, <B>B>uuid_to_string()<B>B> (:std) my $uuid_str = UUID_to_string($uuid); <B>B>string_to_UUID()<B>B>, <B>B>string_to_uuid()<B>B> (:std) my $uuid = string_to_UUID($uuid_str);
In addition to the standard UUID string representation and its URN forms (starting with urn:uuid: or uuid:), this function accepts 32 digit hex strings, variants with different positions of - and Base64 encoded UUIDs.
If you want to make sure to have a pure standard UUID representation, check with is_UUID_string!
<B>B>version_of_UUID()<B>B>, <B>B>version_of_uuid()<B>B> (:std) my $version = version_of_UUID($uuid);
This function accepts binary and string UUIDs.
<B>B>time_of_UUID()<B>B>, <B>B>time_of_uuid()<B>B> (:std) my $uuid_time = time_of_UUID($uuid);
This function accepts UUIDs and UUID strings. Returns the time as a floating point value, so use int() to get a time() compatible value.
<B>B>clk_seq_of_UUID()<B>B>, <B>B>clk_seq_of_uuid()<B>B> (:std) my $uuid_clk_seq = clk_seq_of_UUID($uuid); <B>B>equal_UUIDs()<B>B>, <B>B>equal_uuids()<B>B> (:std) my $bool = equal_UUIDs($uuid1, $uuid2);
<B>Why version 1 only with random multi-cast MAC addresses?B> The random multi-cast MAC address gives privacy, and getting the real MAC address with Perl is really dirty (and slow); <B>Should version 3 or version 5 be used?B> Using SHA-1 reduces the probability of collisions and provides a better randomness of the resulting UUID compared to MD5. Version 5 is recommended in RFC 4122 if backward compatibility is not an issue.
See RFC 4122 (<http://www.ietf.org/rfc/rfc4122.txt>) for technical details on UUIDs. Wikipedia gives a more palatable description at <http://en.wikipedia.org/wiki/Universally_unique_identifier>.
Christian Augustin, <mail at caugustin.de>
Some of this code is based on UUID::Generator by ITO Nobuaki <firstname.lastname@example.org>. But that module is announced to be marked as deprecated in the future and it is much too complicated for my liking.
Jesse Vincent, <jesse at bestpractical.com>, improved version 1.02 with his tips and a heavy refactoring.
Please report any bugs or feature requests to bug-uuid-tiny at rt.cpan.org, or through the web interface at <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=UUID-Tiny>. I will be notified, and then youll automatically be notified of progress on your bug as I make changes.
You can find documentation for this module with the perldoc command.
You can also look for information at:
o RT: CPANs request tracker
o AnnoCPAN: Annotated CPAN documentation o CPAN Ratings o Search CPAN
Kudos to ITO Nobuaki <email@example.com> for his UUID::Generator::PurePerl module! My work is based on his code, and without it I wouldve been lost with all those incomprehensible RFC texts and C codes ...
Thanks to Jesse Vincent (<jesse at bestpractical.com>) for his feedback, tips and refactoring!
Copyright 2009, 2010, 2013 Christian Augustin, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
ITO Nobuaki has very graciously given me permission to take over copyright for the portions of code that are copied from or resemble his work (see rt.cpan.org #53642 <https://rt.cpan.org/Public/Bug/Display.html?id=53642>).
|perl v5.20.3||UUID::TINY (3)||2013-08-19|