1docs::api::ModPerl::UtiUls(e3r)Contributed Perl Documentdaotciso:n:api::ModPerl::Util(3)
2
3
4
6 ModPerl::Util - Helper mod_perl Functions
7
9 use ModPerl::Util;
10
11 # e.g. PerlResponseHandler
12 $callback = ModPerl::Util::current_callback;
13
14 # exit w/o killing the interpreter
15 ModPerl::Util::exit();
16
17 # untaint a string (do not use it! see the doc)
18 ModPerl::Util::untaint($string);
19
20 # removes a stash (.so, %INC{$stash}, etc.) as best as it can
21 ModPerl::Util::unload_package($stash);
22
23 # current perl's address (0x92ac760 or 0x0 under non-threaded perl)
24 ModPerl::Util::current_perl_id();
25
27 "ModPerl::Util" provides mod_perl utilities API.
28
30 "ModPerl::Util" provides the following functions and/or methods:
31
32 "current_callback"
33 Returns the currently running callback name, e.g.
34 'PerlResponseHandler'.
35
36 $callback = ModPerl::Util::current_callback();
37
38 ret: $callback ( string )
39 since: 2.0.00
40
41 "current_perl_id"
42 Return the memory address of the perl interpreter
43
44 $perl_id = ModPerl::Util::current_perl_id();
45
46 ret: $perl_id ( string )
47 Under threaded perl returns something like: 0x92ac760
48
49 Under non-thread perl returns 0x0
50
51 since: 2.0.00
52
53 Mainly useful for debugging applications running under threaded-perl.
54
55 "exit"
56 Terminate the request, but not the current process (or not the current
57 Perl interpreter with threaded mpms).
58
59 ModPerl::Util::exit($status);
60
61 opt arg1: $status ( integer )
62 The exit status, which as of this writing is ignored. (it's
63 accepted to be compatible with the core "exit" function.)
64
65 ret: no return value
66 since: 2.0.00
67
68 Normally you will use the plain exit() in your code. You don't need to
69 use "ModPerl::Util::exit" explicitly, since mod_perl overrides exit()
70 by setting "CORE::GLOBAL::exit" to "ModPerl::Util::exit". Only if you
71 redefine "CORE::GLOBAL::exit" once mod_perl is running, you may want to
72 use this function.
73
74 The original exit() is still available via CORE::exit().
75
76 "ModPerl::Util::exit" is implemented as a special die() call, therefore
77 if you call it inside "eval BLOCK" or "eval "STRING"", while an
78 exception is being thrown, it is caught by "eval". For example:
79
80 exit;
81 print "Still running";
82
83 will not print anything. But:
84
85 eval {
86 exit;
87 }
88 print "Still running";
89
90 will print Still running. So you either need to check whether the
91 exception is specific to "exit" and call exit() again:
92
93 use ModPerl::Const -compile => 'EXIT';
94 eval {
95 exit;
96 }
97 exit if $@ && ref $@ eq 'APR::Error' && $@ == ModPerl::EXIT;
98 print "Still running";
99
100 or use CORE::exit():
101
102 eval {
103 CORE::exit;
104 }
105 print "Still running";
106
107 and nothing will be printed. The problem with the latter is the current
108 process (or a Perl Interpreter) will be killed; something that you
109 really want to avoid under mod_perl.
110
111 "unload_package"
112 Unloads a stash from the current Perl interpreter in the safest way
113 possible.
114
115 ModPerl::Util::unload_package($stash);
116
117 arg1: $stash ( string )
118 The Perl stash to unload. e.g. "MyApache2::MyData".
119
120 ret: no return value
121 since: 2.0.00
122
123 Unloading a Perl stash (package) is a complicated business. This
124 function tries very hard to do the right thing. After calling this
125 function, it should be safe to use() a new version of the module that
126 loads the wiped package.
127
128 References to stash elements (functions, variables, etc.) taken from
129 outside the unloaded package will still be valid.
130
131 This function may wipe off things loaded by other modules, if the
132 latter have inserted things into the $stash it was told to unload.
133
134 If a stash had a corresponding XS shared object (.so) loaded it will be
135 unloaded as well.
136
137 If the stash had a corresponding entry in %INC, it will be removed from
138 there.
139
140 unload_package() takes care to leave sub-stashes intact while deleting
141 the requested stash. So for example if "CGI" and "CGI::Carp" are
142 loaded, calling unload_package('CGI') won't affect "CGI::Carp".
143
144 "untaint"
145 Untaint the variable, by turning its tainted SV flag off (used
146 internally).
147
148 ModPerl::Util::untaint($tainted_var);
149
150 arg1: $tainted_var (scalar)
151 ret: no return value
152 $tainted_var is untainted.
153
154 since: 2.0.00
155
156 Do not use this function unless you know what you are doing. To learn
157 how to properly untaint variables refer to the perlsec manpage.
158
160 mod_perl 2.0 documentation.
161
163 mod_perl 2.0 and its core modules are copyrighted under The Apache
164 Software License, Version 2.0.
165
167 The mod_perl development team and numerous contributors.
168
169
170
171perl v5.36.0 2023-01-19 docs::api::ModPerl::Util(3)