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 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