יובל קוג'מן (Yuval Kogman) > Data-UUID-LibUUID > Data::UUID::LibUUID

Download:
Data-UUID-LibUUID-0.04.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
Report a bug
Module Version: 0.04   Source  

NAME ^

Data::UUID::LibUUID - uuid.h based UUID generation (versions 1, 2 and 4)

SYNOPSIS ^

    use Data::UUID::LibUUID;

    my $uuid = new_uuid_string();

DESCRIPTION ^

This module provides bindings for libuuid shipped with e2fsprogs or uuid-dev on debian, and also works with the system uuid.h on darwin.

EXPORTS ^

new_uuid_string $version
new_uuid_binary $version

Returns a new UUID in string (dash separated hex) or binary (16 octets) format.

$version can be 1, 2, or 4 and defaults to 2.

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

Version 4 is based just on random data. This is not guaranteed to be high quality random data.

uuid_to_binary $str_or_bin

Converts a UUID from string or binary format to binary format.

Returns undef on a non UUID argument.

uuid_to_string $str_or_bin

Converts a UUID from string or binary format to string format.

Returns undef on a non UUID argument.

uuid_eq $str_or_bin, $str_or_bin

Checks if two UUIDs are equivalent. Returns true if they are, or false if they aren't.

Returns undef on non UUID arguments.

uuid_compare $str_or_bin, $str_or_bin

Returns -1, 0 or 1 depending on the lexicographical order of the UUID. This works like the cmp builtin.

Returns undef on non UUID arguments.

new_dce_uuid_string
new_dce_uuid_binary

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.

TODO ^

SEE ALSO ^

Data::GUID, Data::UUID, UUID, http://e2fsprogs.sourceforge.net/

VERSION CONTROL ^

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.

AUTHOR ^

Yuval Kogman <nothingmuch@woobling.org>

COPYRIGHT ^

    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.