.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "autodie::Util 3perl" .TH autodie::Util 3perl 2024-05-30 "perl v5.38.2" "Perl Programmers Reference Guide" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME autodie::Util \- Internal Utility subroutines for autodie and Fatal .SH SYNOPSIS .IX Header "SYNOPSIS" .Vb 1 \& # 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\en"; }); .Ve .SH DESCRIPTION .IX Header "DESCRIPTION" Internal Utilities for autodie and Fatal! This module is not a part of autodie's public API. .PP This module contains utility subroutines for abstracting away the underlying magic of autodie and (ab)uses of \f(CW\*(C`%^H\*(C'\fR to call subs at the end of a (compile-time) scopes. .PP Note that due to how \f(CW\*(C`%^H\*(C'\fR 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 \f(CW\*(C`%^H\*(C'\fR. .SS Methods .IX Subsection "Methods" \fIon_end_of_compile_scope\fR .IX Subsection "on_end_of_compile_scope" .PP .Vb 1 \& on_end_of_compile_scope(sub { print "Hallo world\en"; }); .Ve .PP 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). .PP \fIfill_protos\fR .IX Subsection "fill_protos" .PP .Vb 1 \& fill_protos(\*(Aq*$$;$@\*(Aq) .Ve .PP 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. .PP 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/[@#]_/. .PP \fImake_core_trampoline\fR .IX Subsection "make_core_trampoline" .PP .Vb 1 \& make_core_trampoline(\*(AqCORE::open\*(Aq, \*(Aqmain\*(Aq, prototype(\*(AqCORE::open\*(Aq)) .Ve .PP 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. .PP If we could reliably use `goto &` on core builtins, we wouldn't need this subroutine. .PP \fIinstall_subs\fR .IX Subsection "install_subs" .PP .Vb 1 \& install_subs(\*(AqMy::Module\*(Aq, { \*(Aqread\*(Aq => sub { die("Hallo\en"), ... }}) .Ve .PP Given a package name and a hashref mapping names to a subroutine reference (or \f(CW\*(C`undef\*(C'\fR), this subroutine will install said subroutines on their given name in that module. If a name mapes to \f(CW\*(C`undef\*(C'\fR, any subroutine with that name in the target module will be removed (possibly "unshadowing" a CORE sub of same name). .SH AUTHOR .IX Header "AUTHOR" Copyright 2013\-2014, Niels Thykier .SH LICENSE .IX Header "LICENSE" This module is free software. You may distribute it under the same terms as Perl itself.