NAME
Enum::Declare::Common - A curated collection of commonly-needed enums
VERSION
Version 0.01
SYNOPSIS
use Enum::Declare::Common::HTTP;
use Enum::Declare::Common::Calendar;
# HTTP status codes
my $meta = StatusCode();
say OK; # 200
say NotFound; # 404
# HTTP methods
say GET; # "get"
# Calendar
say Monday; # 1
say January; # 1
DESCRIPTION
Enum::Declare::Common provides a collection of frequently used enums built on Enum::Declare. Each submodule declares standard enums with proper constants, export support, and meta objects for introspection and exhaustive matching.
MODULES
Enum::Declare::Common::HTTP — HTTP status codes, methods, and helpers
Enum::Declare::Common::Calendar — Weekday, WeekdayFlag (bitmask), Month
Enum::Declare::Common::Country — ISO 3166-1 alpha-2/3 codes to country names
Enum::Declare::Common::CountryISO — ISO 3166-1 alpha-2/3 code-to-code constants
Enum::Declare::Common::Currency — ISO 4217 currency codes to names
Enum::Declare::Common::CurrencyISO — ISO 4217 code-to-code constants
Enum::Declare::Common::MIME — 48 common MIME types
Enum::Declare::Common::Color — 148 named CSS colours with hex values
Enum::Declare::Common::Sort — Direction (Asc/Desc) and NullHandling
Enum::Declare::Common::Bool — YesNo, OnOff, TrueFalse, Bit
Enum::Declare::Common::Priority — Level (1-5) and Severity strings
Enum::Declare::Common::Timezone — Timezone abbreviation constants
Enum::Declare::Common::TimezoneOffset — UTC offsets in seconds
Enum::Declare::Common::Locale — Language/locale tag constants
Enum::Declare::Common::FileType — File type constants
Enum::Declare::Common::Encoding — Character encoding names
Enum::Declare::Common::Permission — Unix permission bits and masks
Enum::Declare::Common::Environment — Application environment names
Enum::Declare::Common::LogLevel — Numeric log levels for comparison
Enum::Declare::Common::Status — Lifecycle status strings
USING WITH Object::Proto
Every enum in this collection is declared with the :Type attribute, which automatically registers it as an Object::Proto type at load time. This means you can use any enum name directly as a slot type:
use Enum::Declare::Common::HTTP qw(:StatusCode :Method);
use Enum::Declare::Common::LogLevel qw(:Level);
use Object::Proto;
object 'APIRequest',
'method:Method:required',
'status:StatusCode',
'log_level:Level:default(' . Info . ')',
;
my $req = new APIRequest method => GET;
$req->status(OK); # accepts valid enum value
$req->status(9999); # dies — not a valid StatusCode
Enum types support coercion, so case-insensitive name lookups work automatically:
$req->status(200); # coerces integer to OK
Note: Enum names must be unique across all loaded modules. For example, Enum::Declare::Common::Bool and Enum::Declare::Common::Permission both declare an enum named Bit, so loading both in the same program will cause a conflict. Import only the specific tags you need.
AUTHOR
LNATION <email@lnation.org>
LICENSE AND COPYRIGHT
This software is Copyright (c) 2026 by LNATION <email@lnation.org>.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 47:
Non-ASCII character seen before =encoding in '—'. Assuming UTF-8