TEST2::UTIL::EXTERNALMETA(3pm)
π
Test2::Util::ExternalMeta β the perl man page, bestie edition β¨
Okay so this one lives in the Perl Programmers Reference Guide (perl), and honestly? It's giving quiet luxury β a tiny module doing a very specific, very important job. Let's get into it π«Ά
πΈ NAME
Test2::Util::ExternalMeta β literally the module that lets third-party tools safely staple meta-data onto your instances without wrecking anything π
π¦ DESCRIPTION
So here's the vibe: this package gives you a clear and consistent way to let third party tools attach meta-data to your instances. If your object consumes this package and imports its methods, then third party meta-data has a safe little home to live in. No cap, that's the whole point β a designated spot so nobody's stepping on anybody's toes π
β¨ SYNOPSIS
First you consume it, like so:
package My::Object;
use strict;
use warnings;
use Test2::Util::ExternalMeta qw/meta get_meta set_meta delete_meta/;
...
And then to actually use it, bestie:
my $inst = My::Object->new;
$inst->set_meta(foo => 'bar');
my $val = $inst->get_meta('foo');
Slay. That's it. That's the whole flow π
π WHERE IS THE DATA STORED?
Okay this part matters, so listen up π
This package assumes your instances are blessed hashrefs β it will not work if that is not true. Fr fr, non-negotiable.
It stores all meta-data in the "_meta" key on your object's hash.
π¨ And here's the warning: if your object makes use of the "_meta" key in its underlying hash, then there is a conflict and you cannot use this package. Periodt. Pick a different key, or don't use this module at all π
π EXPORTS
$val = $obj->meta($key)$val = $obj->meta($key, $default)
This gets the value for a specified meta $key. Normally it returns "undef" when there's no value for that $key, but you can pass a $default value and it'll hand that back when nothing is set yet. Convenient, highkey π
$val = $obj->get_meta($key)
This gets the value for a specified meta $key too β it just doesn't carry the $default overhead that meta() has. Lean and mean β¨
$val = $obj->delete_meta($key)
This removes the value of a specified meta $key. The old $val gets returned to you on the way out, so nothing is lost π
$obj->set_meta($key, $val)
Set the value of a specified meta $key. That's it, that's the whole job π
π« META-KEY RESTRICTIONS
Rules are rules, bestie:
- Meta keys must be defined, and must be true when used as a boolean.
- Keys may not be references.
- You're totally free to stringify a reference with
"$ref"for use as a key β but this package will not stringify it for you. You gotta do it yourself π
π SOURCE
The source code repository for Test2 can be found at <https://github.com/Test-More/test-more/>. Go star it, it's iconic β
π MAINTAINERS
Chad Granum <exodist@cpan.org>
π AUTHORS
Chad Granum <exodist@cpan.org>
π COPYRIGHT
Copyright Chad Granum <exodist@cpan.org>.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
See <https://dev.perl.org/licenses/>
β¨ and that's the whole page, bestie β¨ This was Test2::Util::ExternalMeta(3pm) from perl v5.42.3, dated 2026-11-03 β go forth and safely attach your meta-data π
ππ¦
π¦ where this page comes from
- alpine 3.24: perl-doc 5.42.3-r0 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms