Data::UUID::LibUUID - uuid.h based UUID generation (versions 2 and 4 depending on platform)
use Data::UUID::LibUUID; my $uuid = new_uuid_string();
This module provides bindings for libuuid shipped with e2fsprogs or uuid-dev on debian, and also works with the system uuid.h on darwin.
Returns a new UUID in string (dash separated hex) or binary (16 octets) format.
$version can be either 2, or 4 and defaults to whatever the underlying implementation prefers.
$version
Version 1 is timestamp/MAC based UUIDs, like Data::UUID provides. They reveal time and host information, so they may be considered a security risk.
Version 2 is described here http://www.opengroup.org/onlinepubs/9696989899/chap5.htm#tagcjh_08_02_01_01. It is similar to version 1 but considered more secure.
Version 4 is based just on random data. This is not guaranteed to be high quality random data, but usually is supposed to be.
On MacOS X getpid is called before UUID generation, to ensure UUIDs are unique accross forks. Behavior on other platforms may vary.
getpid
Converts a UUID from string or binary format to binary format.
Returns undef on a non UUID argument.
Converts a UUID from string or binary format to string format.
Checks if two UUIDs are equivalent. Returns true if they are, or false if they aren't.
Returns undef on non UUID arguments.
Returns -1, 0 or 1 depending on the lexicographical order of the UUID. This works like the cmp builtin.
cmp
These two subroutines are a little hackish in that they take no arguments but also do not validate the arguments, so they can be abused as methods:
package MyFoo; use Data::UUID::LibUUID ( new_dce_uuid_string => { -as "generate_uuid" }, ); sub yadda { my $self = shift; my $id = $self->generate_uuid; }
This allows the ID generation code to be subclassed, but still keeps the hassle down to a minimum. DCE is UUID version two specification.
Creates a lexically ascending identifier containing a UUID, high resolution timestamp, and a counter.
This is not a UUID (it's longer), but if you can store variable length identifier (and exposing the system clock is not an issue) they can be used to create an identifier that is both universally unique, and lexically increasing.
Note that while the identifiers are universally unique, there is no universal ordering (that would require synchronization), so identifiers generated on different machines or even different process/thread could have IDs which interleave.
Consider bundling libuuid for when no system uuid.h exists.
uuid.h
Data::GUID, Data::UUID, UUID, http://e2fsprogs.sourceforge.net/
This module is maintained using Darcs. You can get the latest version from http://nothingmuch.woobling.org/code, and use darcs send to commit changes.
darcs send
Yuval Kogman <nothingmuch@woobling.org>
Copyright (c) 2008 Yuval Kogman. All rights reserved This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Data::UUID::LibUUID, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Data::UUID::LibUUID
CPAN shell
perl -MCPAN -e shell install Data::UUID::LibUUID
For more information on module installation, please visit the detailed CPAN module installation guide.