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 $key you 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 $default value 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 $default overhead that meta() does, so it's the lighter, faster vibe. πŸ¦‹
  • $val = $obj->delete_meta($key) β€” removes the value of a specified meta $key. The old $val gets 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 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