NAME

iabtcfv2 - shortcut module for one-liner and shell use of GDPR::IAB::TCFv2

SYNOPSIS

use feature qw<say>;
use iabtcfv2;

my $tc_string = 'CLcVDxRMWfGmWAVAHCENAXCkAKDAADnAABRgA5mdfCKZuYJez-NQm0TBMYA4oCAAGQYIAAAAAAEAIAEgAA';

# Parse a TC string and inspect:
my $c = tcf($tc_string);
say $c->cmp_id;
say $c->consent_language;

# Validate:
my $r = validator(
    vendor_id           => 284,
    consent_purpose_ids => [ 1, 3 ],
)->validate($tc_string);
say $r ? "ok" : "fail: $r";

# One-liner from the shell:
#   perl -Miabtcfv2 -E 'say tcf(shift)->cmp_id' "$tc"

DESCRIPTION

iabtcfv2 is a pure-exporter shortcut module for one-liner and shell use of the GDPR-IAB-TCFv2 distribution. It exports two constructor shortcuts so that perl -Miabtcfv2 -E '...' can write tcf($s) and validator(%opts) instead of the full-namespace forms.

iabtcfv2 is intentionally not an inheritance hub: there is no @ISA, and class-method calls like iabtcfv2->Parse(...) are deliberately not supported. Use tcf() for one-liners, or call GDPR::IAB::TCFv2->Parse(...) on the hub for OO invocation in full scripts.

For the full parser API see GDPR::IAB::TCFv2::Parser. For declarative validation see GDPR::IAB::TCFv2::Validator. For project overview see GDPR::IAB::TCFv2.

EXPORTS

Both functions are exported automatically on use iabtcfv2;.

tcf

my $consent = tcf($tc_string);

Shortcut for GDPR::IAB::TCFv2::Parser->Parse($tc_string). Returns a GDPR::IAB::TCFv2::Parser instance.

validator

my $v = validator(
    vendor_id           => 284,
    consent_purpose_ids => [ 1, 3 ],
);

Shortcut for GDPR::IAB::TCFv2::Validator->new(%opts). Returns a GDPR::IAB::TCFv2::Validator instance. Pass to $v->validate($tc_string) for a fail-fast check.

SEE ALSO

GDPR::IAB::TCFv2, GDPR::IAB::TCFv2::Parser, GDPR::IAB::TCFv2::Validator.

The IAB TCF v2 specification: https://github.com/InteractiveAdvertisingBureau/GDPR-Transparency-and-Consent-Framework/blob/master/TCFv2/IAB%20Tech%20Lab%20-%20Consent%20string%20and%20vendor%20list%20formats%20v2.md.

AUTHOR

Tiago Peczenyj mailto:tiago.peczenyj+cpan@gmail.com

LICENSE AND COPYRIGHT

Copyright 2023-2026 Tiago Peczenyj.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.