autodie::Util(3perl)
๐ autodie::Util โ bestie edition ๐
So this is autodie::Util, part of the Perl Programmers Reference Guide, and it's the little internal toolbox that keeps autodie and Fatal ticking. ๐
โจ NAME โจ
autodie::Util โ Internal Utility subroutines for autodie and Fatal ๐ ๏ธ
๐ธ SYNOPSIS ๐ธ
# INTERNAL API for autodie and Fatal only!
use autodie::Util qw(on_end_of_compile_scope);
on_end_of_compile_scope(sub { print "Hallo world\n"; });
๐ฆ DESCRIPTION ๐ฆ
okay so Internal Utilities for autodie and Fatal! This module is not a part of autodie's public API, bestie. It's the backstage area. ๐
This module contains utility subroutines for abstracting away the underlying magic of autodie and (ab)uses of "%^H" to call subs at the end of a (compile-time) scopes.
Note that due to how "%^H" works, some of these utilities are only useful during the compilation phase of a perl module and relies on the internals of how perl handles references in "%^H". ๐
iykyk
๐ฅ Methods ๐ฅ
โญ on_end_of_compile_scope
on_end_of_compile_scope(sub { print "Hallo world\n"; });
Will invoke a sub at the end of a (compile-time) scope. The sub is called once with no arguments. Can be called multiple times (even in the same "compile-time" scope) to install multiple subs. Subs are called in a "first-in-last-out"-order (FILO or "stack"-order). ๐ฅโจ
โญ fill_protos
fill_protos('*$$;$@')
Given a Perl subroutine prototype, return a list of invocation specifications. Each specification is a listref, where the first member is the (minimum) number of arguments for this invocation specification. The remaining arguments are a string representation of how to pass the arguments correctly to a sub with the given prototype, when called with the given number of arguments. ๐งฎ
The specifications are returned in increasing order of arguments starting at 0 (e.g. ';$') or 1 (e.g. '$@'). Note that if the prototype is "slurpy" (e.g. ends with a "@"), the number of arguments for the last specification is a "minimum" number rather than an exact number. This can be detected by the last member of the last specification matching m/[@#]_/. ๐
โญ make_core_trampoline
make_core_trampoline('CORE::open', 'main', prototype('CORE::open'))
Creates a trampoline for calling a core sub. Essentially, a tiny sub that figures out how we should be calling our core sub, puts in the arguments in the right way, and bounces our control over to it. ๐คธโ๏ธโจ
If we could reliably use `goto &` on core builtins, we wouldn't need this subroutine. ๐
โญ install_subs
install_subs('My::Module', { 'read' => sub { die("Hallo\n"), ... }})
Given a package name and a hashref mapping names to a subroutine reference (or "undef"), this subroutine will install said subroutines on their given name in that module. If a name mapes to "undef", any subroutine with that name in the target module will be removed (possibly "unshadowing" a CORE sub of same name). ๐ซถ
๐ AUTHOR ๐
Copyright 2013-2014, Niels Thykier <niels@thykier.net> ๐
๐ LICENSE ๐
This module is free software. You may distribute it under the same terms as Perl itself. ๐
and that's the whole vibe check, bestie โ this page is from perl v5.44.0, dated 2026-10-17 (autodie::Util(3perl)). slay, go forth and compile ๐โจ๐ฆ
๐ฆ 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