TEST2::UTIL::EXTERNALMETA(3perl)
π Test2::Util::ExternalMeta π
okay bestie, so this is a page from the Perl Programmers Reference Guide β specifically the Test2::Util::ExternalMeta manual β and we are going to make it make sense, no cap. π
π¦ NAME π¦
Test2::Util::ExternalMeta β it lets third party tools safely stick meta-data onto your instances. Let them cook, but safely. β¨
πΈ DESCRIPTION πΈ
So basically this package gives you a clean, consistent, iconic way to let third party tools attach meta-data to your instances. If your object consumes this package and imports its methods, then all that third-party meta-data has a safe little home to live in. It's giving... boundaries, but make it friendly. π
β¨ SYNOPSIS β¨
First you set it up like this:
package My::Object;
use strict;
use warnings;
use Test2::Util::ExternalMeta qw/meta get_meta set_meta delete_meta/;
...
And now to actually use it:
my $inst = My::Object->new;
$inst->set_meta(foo => 'bar');
my $val = $inst->get_meta('foo');
look at that. gorgeous. the data goes in, the data comes out. π₯
π WHERE IS THE DATA STORED? π
Real talk: this package assumes your instances are blessed hashrefs. If that's not true, it will not work. Periodt.
It stores all meta-data in the "_meta" key on your object's hash. So if your object is already using the "_meta" key in its underlying hash, that's a conflict and you cannot use this package. π Pick a different key, bestie, or don't use this at all.
π EXPORTS π
$val = $obj->meta($key)β grabs the value for the meta$keyyou specified. Normally this returns"undef"when there's no value for that$key, but...$val = $obj->meta($key, $default)β same deal, but you can pass a$defaultvalue to set when no value is already set. Very thoughtful of it, honestly.$val = $obj->get_meta($key)β gets the value for a specified meta$key. This one doesn't have the$defaultoverhead thatmeta()does, so it's the lighter, faster vibe. π¦$val = $obj->delete_meta($key)β removes the value of a specified meta$key. The old$valgets returned to you. It's not gone, it's just graduated. π$obj->set_meta($key, $val)β sets the value of a specified meta$key. That's it, that's the whole thing. π
π META-KEY RESTRICTIONS π
Meta keys must be defined, and must be true when used as a boolean. Keys may not be references. That's a hard no on refs, bestie. π«
You are free to stringify a reference yourself with "$ref" and use that as a key β but this package will not stringify it for you. Do the work yourself, iykyk. β¨
π«Ά SOURCE π«Ά
The source code repository for Test2 lives right here:
<https://github.com/Test-More/test-more/>
go be nosy, it's encouraged. π
π 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 written for perl v5.44.0, dated 2026-10-17 β thx for reading, stan the docs, mwah π§π
π¦ where this page comes from
- arch rolling: perl 5.44.0-1 Β· Artistic-1.0-Perl AND GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms