NAME

Mail::DKIM2::TagValueList - The tag=value list a DKIM2 header is made of

SYNOPSIS

use Mail::DKIM2::TagValueList;

my $tvl = Mail::DKIM2::TagValueList->parse("i=1; d=example.com");
say $tvl->get_tag('d');   # "example.com"

$tvl->set_tag('t', time);
say $tvl->as_string;      # "i=1; d=example.com; t=1740000000"

DESCRIPTION

A semicolon-separated list of tag=value pairs (-07 section 2.12 and 8). Tag names keep their original case and order, and values their internal whitespace; serialisation joins name=value pairs with ; , so the whitespace around = and ; and a trailing ; are normalised (harmless for signing input, which -07 section 12.8 strips of all whitespace). Lookups are case-insensitive. Mail::DKIM2::Signature is a subclass.

CONSTRUCTORS

new()

An empty list.

parse($string)

Parses a list into a new object (also when called on an existing one), trimming whitespace around names and values. A tag given twice (in any case) is reported by duplicate_tag, and a field that is not a valid tag list by syntax_error; the verifier rejects either.

METHODS

get_tag($name)

The value of the tag, matched case-insensitively, or undef.

set_tag($name, $value)

Sets a tag, appending it to the order if new.

duplicate_tag()

The lowercased name of a tag that appeared more than once in the parsed input, or undef. Section 8 allows one of each; the Verifier reports a repeat as a permerror.

syntax_error()

True if the parsed input did not match the tag-list grammar (-07 section 8): an empty fragment before the end (;;; one trailing ; is fine), a fragment that is not name=value, a name not starting with a letter, or a value with a character outside printable ASCII or a ;. The well-formed tags are still available, for diagnostics.

as_string()

The list serialised in its original order, "; " between pairs.

FUNCTIONS

split_tag_list($string)

Splits a tag list into an arrayref of [name, value] pairs, whitespace trimmed, and returns it with a flag that is false if any fragment was malformed: my ($pairs, $ok) = split_tag_list($s).

AUTHOR

Bron Gondwana <brong@fastmailteam.com>

COPYRIGHT AND LICENSE

Copyright (c) 2025-2026 Fastmail Pty Ltd. This is free software; you can redistribute it and/or modify it under the same terms as Perl itself.