OSSP::uuid(3perl)
π OSSP::uuid β the Perl binding, bestie edition π
okay so this is OSSP::uuid, from the 3perl manual section, and it's the Perl glow-up of the OSSP uuid library. sit with me, we're gonna go through the whole thing. no skipping. β¨
πΈ NAME πΈ
OSSP::uuid β the OSSP uuid Perl Binding. that's it, that's the name, she's serving exactly what it says on the tin. π
β¨ DESCRIPTION β¨
so. OSSP uuid is a ISO-C:1999 application programming interface (API) and a corresponding command line interface (CLI) for generating Universally Unique Identifier (UUID) values that comply with RFC 9562, ISO/IEC 11578:1996 and IETF RFC-4122. she's compliant with all of them, she's an overachiever, we love her. π
she supports DCE 1.1 variant UUIDs of these versions:
- version 1 β time and node based β°
- version 3 β name based, MD5 π
- version 4 β random number based π²
- version 5 β name based, SHA-1 π
and there are additional API bindings provided for the Perl:5 language (hi, that's us π«Ά). plus, optional backward compatibility exists for the ISO-C DCE-1.1 and Perl Data::UUID APIs, in case you're running old code and can't let go. no judgment, i get it.
OSSP::uuid is the Perl binding to the OSSP uuid API, and it comes in three delicious variants. pick your fighter:
π TIE-STYLE API π
the TIE-style API is a functionality-reduced wrapper around the OO-style API and it's intended for very high-level convenience programming. it's the "just make it work, i'm tired" option. π
use OSSP::uuid;
tie my $uuid, 'OSSP::uuid::tie', $mode, ...;
$uuid = [ $mode, ... ];
print "UUID=$uuid\n";
untie $uuid;
π¦ OO-STYLE API π¦
the OO-style API is a wrapper around the C-style API and it's intended for high-level regular programming. this is the everyday main character. β¨
use OSSP::uuid;
my $uuid = new OSSP::uuid;
$uuid->load ($name);
$uuid->make ($mode, ...);
$result = $uuid->isnil();
$result = $uuid->compare($uuid2);
$uuid->import($fmt, $data_ptr);
$data_ptr = $uuid->export($fmt);
[(]$str[, $rc)] = $uuid->error();
$ver = $uuid->version();
undef $uuid;
additionally β and this is the cute part β the strings "v1", "v3", "v4", "v5", "v6", "v7", and "mc" can be used in $mode, and the strings "bin", "str", and "txt" can be used in $fmt. short, sweet, iconic. π
π C-STYLE API π
the C-style API is a direct mapping of the OSSP uuid ISO-C API to Perl, and it's intended for low-level programming. we're down in the engine room now. see uuid(3) for a description of the functions and their expected arguments.
use OSSP::uuid qw(:all);
my $uuid; $rc = uuid_create($uuid);
$rc = uuid_load($uuid, $name);
$rc = uuid_make($uuid, $mode, ...);
$rc = uuid_isnil($uuid, $result);
$rc = uuid_ismax($uuid, $result);
$rc = uuid_compare($uuid, $uuid2, $result);
$rc = uuid_import($uuid, $fmt, $data_ptr, $data_len);
$rc = uuid_export($uuid, $fmt, $data_ptr, $data_len);
$str = uuid_error($rc);
$ver = uuid_version();
$rc = uuid_destroy($uuid);
additionally, the following constants are exported for use in $rc, $mode, $fmt, and $ver β here's the full squad, all of them, not a single one left behind:
UUID_VERSIONUUID_LEN_BINUUID_LEN_STRUUID_RC_OKUUID_RC_ARGUUID_RC_MEMUUID_RC_SYSUUID_RC_INTUUID_RC_IMPUUID_MAKE_V1UUID_MAKE_V3UUID_MAKE_V4UUID_MAKE_V5UUID_MAKE_MCUUID_MAKE_V6UUID_MAKE_V7UUID_FMT_BINUUID_FMT_STRUUID_FMT_SIVUUID_FMT_TXT
π EXAMPLES π
okay bestie, here's where it all clicks. the following two examples create the version 3 UUID 02d9e6d5-9467-382e-8f9b-9300a64ac3cd, both via the OO-style and the C-style API. (yes, that's a real value, and yes, it slaps. π₯)
heads up though β error handling is omitted here for easier reading, but it has to be added for production-quality code. do not ship the vibes-only version. i'm serious. π
# 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";
three flavours, same delicious UUID. it's giving range. π
π SEE ALSO π
go read these next, they're all part of the same friend group:
π HISTORY π
the Perl binding OSSP::uuid to OSSP uuid was implemented in November 2004 by Ralf S. Engelschall <rse@engelschall.com>. legend behavior, honestly. π
and that's the whole page, bestie, you ate it. π«Ά this was OSSP::uuid(3perl) from ossp-uuid 1.6.6, dated December 8, 2025 β go make some UUIDs, you've got this. πβ¨π
π¦ where this page comes from
- ubuntu resolute: libossp-uuid-perl 1.6.6-1 Β· OSSP
- ubuntu stonking: libossp-uuid-perl 1.6.6-1build1 Β· OSSP
- Copyright (c) 2004-2007 Ralf S. Engelschall <rse@engelschall.com>
- Copyright (c) 2004-2007 The OSSP Project <http://www.ossp.org/>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms