|
NAMEUUID::Tiny - Pure Perl UUID Support With Functional InterfaceVERSIONVersion 1.04SYNOPSISCreate version 1, 3, 4 and 5 UUIDs:use UUID::Tiny ':std'; my $v1_mc_UUID = create_uuid(); my $v1_mc_UUID_2 = create_uuid(UUID_V1); my $v1_mc_UUID_3 = create_uuid(UUID_TIME); my $v3_md5_UUID = create_uuid(UUID_V3, $str); my $v3_md5_UUID_2 = create_uuid(UUID_MD5, UUID_NS_DNS, 'caugustin.de'); my $v4_rand_UUID = create_uuid(UUID_V4); my $v4_rand_UUID_2 = create_uuid(UUID_RANDOM); my $v5_sha1_UUID = create_uuid(UUID_V5, $str); my $v5_with_NS_UUID = create_uuid(UUID_SHA1, UUID_NS_DNS, 'caugustin.de'); my $v1_mc_UUID_string = create_uuid_as_string(UUID_V1); my $v3_md5_UUID_string = uuid_to_string($v3_md5_UUID); if ( version_of_uuid($v1_mc_UUID) == 1 ) { ... }; if ( version_of_uuid($v5_sha1_UUID) == 5 ) { ... }; if ( is_uuid_string($v1_mc_UUID_string) ) { ... }; if ( equal_uuids($uuid1, $uuid2) ) { ... }; my $uuid_time = time_of_uuid($v1_mc_UUID); my $uuid_clk_seq = clk_seq_of_uuid($v1_mc_UUID); DESCRIPTIONUUID::Tiny is a lightweight, low dependency Pure Perl module for UUID creation and testing. This module provides the creation of version 1 time based UUIDs (using random multicast MAC addresses), version 3 MD5 based UUIDs, version 4 random UUIDs, and version 5 SHA-1 based UUIDs.ATTENTION! UUID::Tiny uses Perl's "rand()" to create the basic random numbers, so the created v4 UUIDs are not cryptographically strong! No fancy OO interface, no plethora of different UUID representation formats and transformations - just string and binary. Conversion, test and time functions equally accept UUIDs and UUID strings, so don't bother to convert UUIDs for them! Continuing with 1.0x versions all constants and public functions are exported by default, but this will change in the future (see below). UUID::Tiny deliberately uses a minimal functional interface for UUID creation (and conversion/testing), because in this case OO looks like overkill to me and makes the creation and use of UUIDs unnecessarily complicated. If you need raw performance for UUID creation, or the real MAC address in version 1 UUIDs, or an OO interface, and if you can afford module compilation and installation on the target system, then better look at other CPAN UUID modules like Data::UUID. This module is "fork safe", especially for random UUIDs (it works around Perl's rand() problem when forking processes). This module is currently not "thread safe". Even though I've incorporated some changes proposed by Michael G. Schwern (thanks!), Digest::MD5 and Digest::SHA seem so have trouble with threads. There is a test file for threads, but it is de-activated. So use at your own risk! DEPENDENCIESThis module should run from Perl 5.8 up and uses mostly standard (5.8 core) modules for its job. No compilation or installation required. These are the modules UUID::Tiny depends on:Carp Digest::MD5 Perl 5.8 core Digest::SHA Perl 5.10 core (or Digest::SHA1, or Digest::SHA::PurePerl) MIME::Base64 Perl 5.8 core Time::HiRes Perl 5.8 core POSIX Perl 5.8 core If you are using this module on a Perl prior to 5.10 and you don't have Digest::SHA1 installed, you can use Digest::SHA::PurePerl instead. ATTENTION! NEW STANDARD INTERFACEAfter some debate I'm convinced that it is more Perlish (and far easier to write) to use all-lowercase function names - without exceptions. And that it is more polite to export symbols only on demand.While the 1.0x versions will continue to export the old, "legacy" interface on default, the future standard interface is available using the ":std" tag on import from version 1.02 on: use UUID::Tiny ':std'; my $md5_uuid = create_uuid(UUID_MD5, $str); In preparation for future version of UUID::Tiny you have to use the ":legacy" tag if you want to stay with the version 1.0 interface: use UUID::Tiny ':legacy'; my $md5_uuid = create_UUID(UUID_V3, $str); CONSTANTS
FUNCTIONSAll 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.
DISCUSSION
UUID DEFINITIONSee 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>.AUTHORChristian Augustin, "<mail at caugustin.de>"CONTRIBUTORSSome of this code is based on UUID::Generator by ITO Nobuaki <banb@cpan.org>. But that module is announced to be marked as "deprecated" in the future and it is much too complicated for my liking.So I decided to reduce it to the necessary parts and to re-implement those parts with a functional interface ... Jesse Vincent, "<jesse at bestpractical.com>", improved version 1.02 with his tips and a heavy refactoring. Michael G. Schwern provided a patch for better thread support (as far as UUID::Tiny can be improved itself) that is incorporated in version 1.04. BUGSPlease 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 you'll automatically be notified of progress on your bug as I make changes.SUPPORTYou can find documentation for this module with the perldoc command.perldoc UUID::Tiny You can also look for information at:
ACKNOWLEDGEMENTSKudos to ITO Nobuaki <banb@cpan.org> for his UUID::Generator::PurePerl module! My work is based on his code, and without it I would've 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 & LICENSECopyright 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>).
Visit the GSP FreeBSD Man Page Interface. |