Test2:...:Stash(3perl)

πŸ’– Test2::Util::Stash β€” the perl manual, but make it cute πŸ’–

okay so bestie, we're talking about Test2::Util::Stash from the 3perl section of the manual (Perl Programmers Reference Guide, no big deal, just iconic behavior). Sit down, grab a boba, because this one is actually so useful once it clicks πŸ§‹βœ¨


🌸 NAME 🌸

Test2::Util::Stash β€” utilities for manipulating stashes and globs. Yeah. Stashes AND globs. The whole symbol-table situation. It's giving backstage pass to perl's internals πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

So basically this module is a whole little collection of utilities for manipulating and inspecting package stashes and globs. That's it, that's the vibe. It's the toolbox you reach for when you need to poke at a package's symbol table and you don't wanna hand-roll *{...} derefs like some kind of feral gremlin 😭


✨ EXPORTS ✨

Every single one of these, listed, no skipping, we don't do that here 🫢

  • $stash = get_stash($package) β€” grabs the package stash for you. This is literally the same thing as writing $stash = \%Package::Name::. Same energy, less typing.
  • $sym_spec = parse_symbol($symbol)
  • $sym_spec = parse_symbol($symbol, $package) β€” parses a symbol name and hands you back a hashref stuffed with info about that symbol. πŸŽ€

Now listen, $symbol can be a simple name or a fully qualified symbol name. The sigil is optional, and if you don't give one, & is just assumed. And heads up β€” if $symbol is fully qualified and you also passed $package, then the symbol's package must match the $package you gave it. No mismatches allowed, it will not let that slide.

You get back a structure like this:

return {
    name    => 'BAZ',
    sigil   => '$',
    type    => 'SCALAR',
    symbol  => '&Foo::Bar::BAZ',
    package => 'Foo::Bar',
};

(yes that's the exact structure, don't come for me, I'm just the messenger πŸ’€)

  • $glob_ref = get_glob($symbol)
  • $glob_ref = get_glob($symbol, $package) β€” gives you a glob ref. The arguments are the same as for parse_symbol, so same rules, same vibes.
  • $ref = get_symbol($symbol)
  • $ref = get_symbol($symbol, $package) β€” gives you a reference to the symbol. Again, arguments are the same as for parse_symbol. Consistency queen πŸ‘‘
  • $ref = purge_symbol($symbol)
  • $ref = purge_symbol($symbol, $package) β€” okay this one completely removes the symbol from the package symbol table. Gone. Deleted. Not coming back. Arguments are the same as for parse_symbol, and you get a reference to the removed symbol returned to you, like a little keepsake of what you just destroyed πŸ”₯
  • $sig = slot_to_sig($slot) β€” converts a slot (like 'SCALAR') into a sigil (like '$').
  • $slot = sig_to_slot($sig) β€” converts a sigil (like '$') into a slot (like 'SCALAR'). It's the inverse, it's the mirror, it's the duality of perl 🌈

πŸ“¦ SOURCE πŸ“¦

The source code repository for Test2-Suite lives at:

https://github.com/Test-More/test-more/

Go look, it's right there, it's free πŸ’œ


πŸ‘‘ MAINTAINERS πŸ‘‘

  • Chad Granum <exodist@cpan.org>

🌟 AUTHORS 🌟

  • Chad Granum <exodist@cpan.org>

(one person, double credit, main character energy fr fr)


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 http://dev.perl.org/licenses/


and that's the whole page bestie, you ate it, every last option and function accounted for, no cap πŸ’…βœ¨

this was Test2:...:Stash(3perl) from perl v5.44.0, dated 2026-10-17 β€” mwah, see you in the next manpage πŸŽ€πŸ’–

πŸ“¦ 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