NAME
ULID::Tiny - A lightweight ULID (Universally Unique Lexicographically Sortable Identifier) generator
SYNOPSIS
use ULID::Tiny qw(ulid ulid_date);
# Generate a new ULID
my $id = ulid(); # e.g. "01ARZ3NDEKTSV4RRFFQ69G5FAV"
# Generate a ULID with a specific timestamp (milliseconds since epoch)
my $id = ulid(time => 1234567890000);
# Extract the timestamp from a ULID (returns milliseconds since epoch)
my $ms = ulid_date($id);
# Generate a ULID in raw 16-byte binary form
my $bytes = ulid(binary => 1);
DESCRIPTION
ULID::Tiny is a minimal, pure Perl, dependency-light module for generating ULIDs.
https://github.com/ulid/spec
A ULID is a 128-bit identifier consisting of:
48-bit millisecond timestamp (first 10 characters)
80-bit cryptographic randomness (last 16 characters)
Key properties:
Lexicographically sortable
Canonically encoded as a 26 character string
Monotonically increasing within the same millisecond
METHODS
- ulid(%opts)
-
Generate a new ULID string. Options:
time- Specify timestamp in milliseconds. Defaults to current time.binary- Returns the raw 16-byte binary ULID instead of an alpha-numeric string.
- ulid_date($ulid_string)
-
Extract the timestamp from a ULID string. Returns the number of milliseconds since the Unix epoch.
RANDOMNESS
The module uses Crypt::SysRandom to get the best source of cryptographic entropy
VERSION
1.0.0
LICENSE
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.