1autodie::Util(3)      User Contributed Perl Documentation     autodie::Util(3)
2
3
4

NAME

6       autodie::Util - Internal Utility subroutines for autodie and Fatal
7

SYNOPSIS

9           # INTERNAL API for autodie and Fatal only!
10
11           use autodie::Util qw(on_end_of_compile_scope);
12           on_end_of_compile_scope(sub { print "Hallo world\n"; });
13

DESCRIPTION

15       Interal Utilities for autodie and Fatal!  This module is not a part of
16       autodie's public API.
17
18       This module contains utility subroutines for abstracting away the
19       underlying magic of autodie and (ab)uses of "%^H" to call subs at the
20       end of a (compile-time) scopes.
21
22       Note that due to how "%^H" works, some of these utilities are only
23       useful during the compilation phase of a perl module and relies on the
24       internals of how perl handles references in "%^H".
25
26   Methods
27       on_end_of_compile_scope
28
29         on_end_of_compile_scope(sub { print "Hallo world\n"; });
30
31       Will invoke a sub at the end of a (compile-time) scope.  The sub is
32       called once with no arguments.  Can be called multiple times (even in
33       the same "compile-time" scope) to install multiple subs.  Subs are
34       called in a "first-in-last-out"-order (FILO or "stack"-order).
35
36       fill_protos
37
38         fill_protos('*$$;$@')
39
40       Given a Perl subroutine prototype, return a list of invocation
41       specifications.  Each specification is a listref, where the first
42       member is the (minimum) number of arguments for this invocation
43       specification.  The remaining arguments are a string representation of
44       how to pass the arguments correctly to a sub with the given prototype,
45       when called with the given number of arguments.
46
47       The specifications are returned in increasing order of arguments
48       starting at 0 (e.g.  ';$') or 1 (e.g.  '$@').  Note that if the
49       prototype is "slurpy" (e.g. ends with a "@"), the number of arguments
50       for the last specification is a "minimum" number rather than an exact
51       number.  This can be detected by the last member of the last
52       specification matching m/[@#]_/.
53
54       make_core_trampoline
55
56         make_core_trampoline('CORE::open', 'main', prototype('CORE::open'))
57
58       Creates a trampoline for calling a core sub.  Essentially, a tiny sub
59       that figures out how we should be calling our core sub, puts in the
60       arguments in the right way, and bounces our control over to it.
61
62       If we could reliably use `goto &` on core builtins, we wouldn't need
63       this subroutine.
64
65       install_subs
66
67         install_subs('My::Module', { 'read' => sub { die("Hallo\n"), ... }})
68
69       Given a package name and a hashref mapping names to a subroutine
70       reference (or "undef"), this subroutine will install said subroutines
71       on their given name in that module.  If a name mapes to "undef", any
72       subroutine with that name in the target module will be remove (possibly
73       "unshadowing" a CORE sub of same name).
74

AUTHOR

76       Copyright 2013-2014, Niels Thykier <niels@thykier.net>
77

LICENSE

79       This module is free software.  You may distribute it under the same
80       terms as Perl itself.
81
82
83
84perl v5.32.0                      2021-01-25                  autodie::Util(3)
Impressum