UnitCheck(3)

πŸ“¦ version 0.13, in alpine 3.24

Hey bestie! Welcome to the UnitCheck(3) page β€” this is the manual for Check::UnitCheck, and it's literally the best of both worlds. πŸ’–

✨ NAME ✨

Check::UnitCheck β€” Use best of CHECK or UNITCHECK. That's the whole vibe. πŸŽ€

🌟 SYNOPSIS 🌟

Okay so you just drop this in your code:

use Check::UnitCheck sub { ... };
# runs sub at best of UNITCHECK or global CHECK, depending

That's it. You're welcome. πŸ’– The comment says it all: it runs your sub at the best of UNITCHECK or global CHECK, depending on what your Perl can handle. Slay. ✨

πŸ’œ DESCRIPTION πŸ’œ

So here's the tea: Perl 5.10.0 will include the UNITCHECK block. This block runs the moment the compilation unit in which it was defined has finished compiling. Iconic behavior, honestly. ✨

But Perl versions before that had only the CHECK block. And CHECK runs once global compilation has completed β€” which might or might not be at the same time that the compilation unit which defines it has finished. It's giving "close enough but not quite." 😭

This module lets you define a block that will run as a UNITCHECK block in Perls that allow that, or as a CHECK block in Perls that do not. So you can use UNITCHECK semantics in a CPAN module, while having a moderately graceful fallback for versions of perl that cannot support that. Bestie, it's literally the best of both worlds. 🫢

Instead of writing:

CHECK {
  ... code ...
}

or

UNITCHECK {
  ... code ...
}

You instead say:

use Check::UnitCheck sub {
  ... code ...
};

At the moment you can only do one sub at once (you can "use" the module more than once, though). In the future extra options might be provided to allow you to inject these blocks into other modules. So stay tuned, iykyk. πŸ‘‘

If you want to push a UNITCHECK block into the queue of a compilation unit that has imported you, then you can do so by calling:

Check::UnitCheck::unitcheckify(sub {...});

directly. No cap, just call it. πŸ’…

⚠️ Warning, bestie: As code passed into the UNITCHECK or CHECK queue is marked as CvSPECIAL, it is probably unwise to use references to named subroutines. So like, don't do that. πŸ™ˆ

πŸŽ€ EXPORT πŸŽ€

None. Like, zero. Nada. This module exports nothing, bestie. It's giving minimalist. πŸ’…

πŸ’€ BUGS πŸ’€

Okay so real talk: perl 5.10 isn't actually available yet, and might not contain UNITCHECK blocks. I'll release a version 0.20 of this module once 5.10 exists and this works with it. Until then, you can use this as a very complicated way of writing CHECK blocks. πŸ’€

So like, it's a work in progress, bestie. Don't come for me. πŸ™ˆ

πŸ‘‘ AUTHOR πŸ‘‘

Shoutout to the main character who wrote this: Alex Gough (alex@earth.li) http://the.earth.li/~alex/. Iconic. πŸ’–

This module is (c) Alex Gough, 2006. You may use and distribute it under the same terms as Perl itself. Slay. πŸŽ€

🌈 SEE ALSO 🌈

  • perl
  • Manip::END

Go check them out, bestie. They're lowkey relevant. πŸ¦‹


And that's the tea! This page is from perl v5.42.2, dated 2026-02-15. Stay iconic, bestie! πŸŒˆπŸ’–πŸ‘‘

πŸ“¦ where this page comes from