.\" .\" OSSP uuid - Universally Unique Identifier .\" Copyright (c) 2004-2007 Ralf S. Engelschall .\" Copyright (c) 2004-2007 The OSSP Project .\" .\" This file is part of OSSP uuid, a library for the generation .\" of UUIDs which can found at http://www.ossp.org/pkg/lib/uuid/ .\" .\" Permission to use, copy, modify, and distribute this software for .\" any purpose with or without fee is hereby granted, provided that .\" the above copyright notice and this permission notice appear in all .\" copies. .\" .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED .\" WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. .\" IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR .\" CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT .\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF .\" USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND .\" ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, .\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT .\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" uuid.pod: Perl Binding (Perl/POD part) .\" .Dd @UUID_VERSION_MDOC_DATE@ .ds doc-volume-operating-system OSSP .Dt OSSP::uuid 3perl .Os ossp-uuid @UUID_VERSION_RAW@ . .Sh NAME .Nm OSSP::uuid .Nd OSSP uuid Perl Binding .Sh DESCRIPTION OSSP .Nm is a ISO-C:1999 application programming interface (API) and corresponding command line interface (CLI) for the generation of RFC 9562, ISO/IEC 11578:1996 and IETF RFC-4122 compliant .Em Universally Unique Identifier (UUID). It supports DCE 1.1 variant UUIDs of version 1 (time and node based), version 3 (name based, MD5), version 4 (random number based) and version 5 (name based, SHA-1). Additional API bindings are provided for the Perl:5 language. Optional backward compatibility exists for the ISO-C DCE-1.1 and Perl Data::UUID APIs. .Pp .Nm is the Perl binding to the OSSP .Nm uuid API. Three variants are provided: . .Ss TIE-STYLE API The TIE-style API is a functionality-reduced wrapper around the OO-style API and intended for very high-level convenience programming: . .Bd -literal -offset 2n use OSSP::uuid; .Ic tie Li my $uuid, 'OSSP::uuid::tie', $mode, ...; $uuid = [ $mode, ... ]; print "UUID=$uuid\\n"; untie $uuid; .Ed . .Ss OO-STYLE API The OO-style API is a wrapper around the C-style API and intended for high-level regular programming. . .Bd -literal -offset 2n use OSSP::uuid; .Li my $uuid = Ic new Li OSSP::uuid; .Li $uuid-> Ns Ic load Li ($name); .Li $uuid-> Ns Ic make Li ($mode, ...); .Li $result = $uuid-> Ns Ic isnil Ns Li (); .Li $result = $uuid-> Ns Ic compare Ns Li ($uuid2); .Li $uuid-> Ns Ic import Ns Ic ($fmt, $data_ptr); .Li $data_ptr = $uuid-> Ns Ic export Ns Li ($fmt); .Li [(]$str[, $rc)] = $uuid-> Ns Ic error Ns Li (); .Li $ver = $uuid-> Ns Ic version Ns Li (); undef $uuid; .Pp .Ed Additionally, the strings .Li \&"v1" , .Li \&"v3" , .Li \&"v4" , .Li \&"v5" , .Li \&"v6" , .Li \&"v7" , and .Li \&"mc" can be used in .Li $mode and the strings .Li \&"bin" , .Li \&"str" , and .Li \&"txt" .Li $fmt . . .Ss C-STYLE API The C-style API is a direct mapping of the OSSP .Nm uuid ISO-C API to Perl and is intended for low-level programming. See .Xr uuid 3 for a description of the functions and their expected arguments. . .Bd -literal -offset 2n use OSSP::uuid qw(:all); .Li my $uuid; $rc = Ic uuid_create Ns Li ($uuid); .Li $rc = Ic uuid_load Ns Li ($uuid, $name); .Li $rc = Ic uuid_make Ns Li ($uuid, $mode, ...); .Li $rc = Ic uuid_isnil Ns Li ($uuid, $result); .Li $rc = Ic uuid_ismax Ns Li ($uuid, $result); .Li $rc = Ic uuid_compare Ns Li ($uuid, $uuid2, $result); .Li $rc = Ic uuid_import Ns Li ($uuid, $fmt, $data_ptr, $data_len); .Li $rc = Ic uuid_export Ns Li ($uuid, $fmt, $data_ptr, $data_len); .Li $str = Ic uuid_error Ns Li ($rc); .Li $ver = Ic uuid_version Ns Li (); .Li $rc = Ic uuid_destroy Ns Li ($uuid); .Ed .Pp Additionally, the following constants are exported for use in .Li $rc , .Li $mode , .Li $fmt , and .Li $ver : .Li UUID_VERSION , .Li UUID_LEN_BIN , .Li UUID_LEN_STR , .Li UUID_RC_OK , .Li UUID_RC_ARG , .Li UUID_RC_MEM , .Li UUID_RC_SYS , .Li UUID_RC_INT , .Li UUID_RC_IMP , .Li UUID_MAKE_V1 , .Li UUID_MAKE_V3 , .Li UUID_MAKE_V4 , .Li UUID_MAKE_V5 , .Li UUID_MAKE_MC , .Li UUID_MAKE_V6 , .Li UUID_MAKE_V7 , .Li UUID_FMT_BIN , .Li UUID_FMT_STR , .Li UUID_FMT_SIV , .Li UUID_FMT_TXT . . .Sh EXAMPLES The following two examples create the version 3 UUID .Li 02d9e6d5-9467-382e-8f9b-9300a64ac3cd , both via the OO-style and the C-style API. Error handling is omitted here for easier reading, but has to be added for production-quality code. . .Bd -literal # TIE-style API (very high-level) use OSSP::uuid; tie my $uuid, 'OSSP::uuid::tie'; $uuid = [ "v1" ]; print "UUIDs: $uuid, $uuid, $uuid\\n"; $uuid = [ "v3", "ns:URL", "http://www.ossp.org/" ]; print "UUIDs: $uuid, $uuid, $uuid\\n"; untie $uuid; # OO-style API (high-level) use OSSP::uuid; my $uuid = new OSSP::uuid; my $uuid_ns = new OSSP::uuid; $uuid_ns->load("ns:URL"); $uuid->make("v3", $uuid_ns, "http://www.ossp.org/"); undef $uuid_ns; my $str = $uuid->export("str"); undef $uuid; print "$str\\n"; # C-style API (low-level) use OSSP::uuid qw(:all); my $uuid; uuid_create($uuid); my $uuid_ns; uuid_create($uuid_ns); uuid_load($uuid_ns, "ns:URL"); uuid_make($uuid, UUID_MAKE_V3, $uuid_ns, "http://www.ossp.org/"); uuid_destroy($uuid_ns); my $str; uuid_export($uuid, UUID_FMT_STR, $str, undef); uuid_destroy($uuid); print "$str\\n"; .Ed . .Sh SEE ALSO .Xr uuid 1 , .Xr uuid-config 1 , .Xr uuid 3 . .Sh HISTORY The Perl binding .Nm to OSSP .Nm uuid was implemented in November 2004 by .An Ralf S. Engelschall Aq rse@engelschall.com .