← Index
NYTProf Performance Profile   « block view • line view • sub view »
For /usr/local/src/github.com/foswiki/core/bin/view
  Run on Sun Dec 4 17:17:59 2011
Reported on Sun Dec 4 17:27:01 2011

Filename/usr/share/perl/5.14/CGI/Carp.pm
StatementsExecuted 28 statements in 3.99ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1113.14ms3.37msCGI::Carp::::BEGIN@335CGI::Carp::BEGIN@335
1111.06ms1.13msCGI::Carp::::BEGIN@333CGI::Carp::BEGIN@333
11155µs258µsCGI::Carp::::importCGI::Carp::import
11110µs10µsCGI::Carp::::BEGIN@340CGI::Carp::BEGIN@340
1113µs3µsCGI::Carp::::CORE:matchCGI::Carp::CORE:match (opcode)
0000s0sCGI::Carp::::_longmessCGI::Carp::_longmess
0000s0sCGI::Carp::::_warnCGI::Carp::_warn
0000s0sCGI::Carp::::carpCGI::Carp::carp
0000s0sCGI::Carp::::carpoutCGI::Carp::carpout
0000s0sCGI::Carp::::cluckCGI::Carp::cluck
0000s0sCGI::Carp::::confessCGI::Carp::confess
0000s0sCGI::Carp::::croakCGI::Carp::croak
0000s0sCGI::Carp::::dieCGI::Carp::die
0000s0sCGI::Carp::::fatalsToBrowserCGI::Carp::fatalsToBrowser
0000s0sCGI::Carp::::idCGI::Carp::id
0000s0sCGI::Carp::::inevalCGI::Carp::ineval
0000s0sCGI::Carp::::realdieCGI::Carp::realdie
0000s0sCGI::Carp::::realwarnCGI::Carp::realwarn
0000s0sCGI::Carp::::set_die_handlerCGI::Carp::set_die_handler
0000s0sCGI::Carp::::set_messageCGI::Carp::set_message
0000s0sCGI::Carp::::set_prognameCGI::Carp::set_progname
0000s0sCGI::Carp::::stampCGI::Carp::stamp
0000s0sCGI::Carp::::to_filehandleCGI::Carp::to_filehandle
0000s0sCGI::Carp::::warnCGI::Carp::warn
0000s0sCGI::Carp::::warningsToBrowserCGI::Carp::warningsToBrowser
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package CGI::Carp;
2
3=head1 NAME
4
5B<CGI::Carp> - CGI routines for writing to the HTTPD (or other) error log
6
7=head1 SYNOPSIS
8
9 use CGI::Carp;
10
11 croak "We're outta here!";
12 confess "It was my fault: $!";
13 carp "It was your fault!";
14 warn "I'm confused";
15 die "I'm dying.\n";
16
17 use CGI::Carp qw(cluck);
18 cluck "I wouldn't do that if I were you";
19
20 use CGI::Carp qw(fatalsToBrowser);
21 die "Fatal error messages are now sent to browser";
22
23=head1 DESCRIPTION
24
25CGI scripts have a nasty habit of leaving warning messages in the error
26logs that are neither time stamped nor fully identified. Tracking down
27the script that caused the error is a pain. This fixes that. Replace
28the usual
29
30 use Carp;
31
32with
33
34 use CGI::Carp
35
36And the standard warn(), die (), croak(), confess() and carp() calls
37will automagically be replaced with functions that write out nicely
38time-stamped messages to the HTTP server error log.
39
40For example:
41
42 [Fri Nov 17 21:40:43 1995] test.pl: I'm confused at test.pl line 3.
43 [Fri Nov 17 21:40:43 1995] test.pl: Got an error message: Permission denied.
44 [Fri Nov 17 21:40:43 1995] test.pl: I'm dying.
45
46=head1 REDIRECTING ERROR MESSAGES
47
48By default, error messages are sent to STDERR. Most HTTPD servers
49direct STDERR to the server's error log. Some applications may wish
50to keep private error logs, distinct from the server's error log, or
51they may wish to direct error messages to STDOUT so that the browser
52will receive them.
53
54The C<carpout()> function is provided for this purpose. Since
55carpout() is not exported by default, you must import it explicitly by
56saying
57
58 use CGI::Carp qw(carpout);
59
60The carpout() function requires one argument, which should be a
61reference to an open filehandle for writing errors. It should be
62called in a C<BEGIN> block at the top of the CGI application so that
63compiler errors will be caught. Example:
64
65 BEGIN {
66 use CGI::Carp qw(carpout);
67 open(LOG, ">>/usr/local/cgi-logs/mycgi-log") or
68 die("Unable to open mycgi-log: $!\n");
69 carpout(LOG);
70 }
71
72carpout() does not handle file locking on the log for you at this point.
73Also, note that carpout() does not work with in-memory file handles, although
74a patch would be welcome to address that.
75
76The real STDERR is not closed -- it is moved to CGI::Carp::SAVEERR. Some
77servers, when dealing with CGI scripts, close their connection to the
78browser when the script closes STDOUT and STDERR. CGI::Carp::SAVEERR is there to
79prevent this from happening prematurely.
80
81You can pass filehandles to carpout() in a variety of ways. The "correct"
82way according to Tom Christiansen is to pass a reference to a filehandle
83GLOB:
84
85 carpout(\*LOG);
86
87This looks weird to mere mortals however, so the following syntaxes are
88accepted as well:
89
90 carpout(LOG);
91 carpout(main::LOG);
92 carpout(main'LOG);
93 carpout(\LOG);
94 carpout(\'main::LOG');
95
96 ... and so on
97
98FileHandle and other objects work as well.
99
100Use of carpout() is not great for performance, so it is recommended
101for debugging purposes or for moderate-use applications. A future
102version of this module may delay redirecting STDERR until one of the
103CGI::Carp methods is called to prevent the performance hit.
104
105=head1 MAKING PERL ERRORS APPEAR IN THE BROWSER WINDOW
106
107If you want to send fatal (die, confess) errors to the browser, ask to
108import the special "fatalsToBrowser" subroutine:
109
110 use CGI::Carp qw(fatalsToBrowser);
111 die "Bad error here";
112
113Fatal errors will now be echoed to the browser as well as to the log. CGI::Carp
114arranges to send a minimal HTTP header to the browser so that even errors that
115occur in the early compile phase will be seen.
116Nonfatal errors will still be directed to the log file only (unless redirected
117with carpout).
118
119Note that fatalsToBrowser may B<not> work well with mod_perl version 2.0
120and higher.
121
122=head2 Changing the default message
123
124By default, the software error message is followed by a note to
125contact the Webmaster by e-mail with the time and date of the error.
126If this message is not to your liking, you can change it using the
127set_message() routine. This is not imported by default; you should
128import it on the use() line:
129
130 use CGI::Carp qw(fatalsToBrowser set_message);
131 set_message("It's not a bug, it's a feature!");
132
133You may also pass in a code reference in order to create a custom
134error message. At run time, your code will be called with the text
135of the error message that caused the script to die. Example:
136
137 use CGI::Carp qw(fatalsToBrowser set_message);
138 BEGIN {
139 sub handle_errors {
140 my $msg = shift;
141 print "<h1>Oh gosh</h1>";
142 print "<p>Got an error: $msg</p>";
143 }
144 set_message(\&handle_errors);
145 }
146
147In order to correctly intercept compile-time errors, you should call
148set_message() from within a BEGIN{} block.
149
150=head1 DOING MORE THAN PRINTING A MESSAGE IN THE EVENT OF PERL ERRORS
151
152If fatalsToBrowser in conjunction with set_message does not provide
153you with all of the functionality you need, you can go one step
154further by specifying a function to be executed any time a script
155calls "die", has a syntax error, or dies unexpectedly at runtime
156with a line like "undef->explode();".
157
158 use CGI::Carp qw(set_die_handler);
159 BEGIN {
160 sub handle_errors {
161 my $msg = shift;
162 print "content-type: text/html\n\n";
163 print "<h1>Oh gosh</h1>";
164 print "<p>Got an error: $msg</p>";
165
166 #proceed to send an email to a system administrator,
167 #write a detailed message to the browser and/or a log,
168 #etc....
169 }
170 set_die_handler(\&handle_errors);
171 }
172
173Notice that if you use set_die_handler(), you must handle sending
174HTML headers to the browser yourself if you are printing a message.
175
176If you use set_die_handler(), you will most likely interfere with
177the behavior of fatalsToBrowser, so you must use this or that, not
178both.
179
180Using set_die_handler() sets SIG{__DIE__} (as does fatalsToBrowser),
181and there is only one SIG{__DIE__}. This means that if you are
182attempting to set SIG{__DIE__} yourself, you may interfere with
183this module's functionality, or this module may interfere with
184your module's functionality.
185
186=head2 SUPPRESSING PERL ERRORS APPEARING IN THE BROWSER WINDOW
187
188A problem sometimes encountered when using fatalsToBrowser is
189when a C<die()> is done inside an C<eval> body or expression.
190Even though the
191fatalsToBrower support takes precautions to avoid this,
192you still may get the error message printed to STDOUT.
193This may have some undesireable effects when the purpose of doing the
194eval is to determine which of several algorithms is to be used.
195
196By setting C<$CGI::Carp::TO_BROWSER> to 0 you can suppress printing the C<die> messages
197but without all of the complexity of using C<set_die_handler>.
198You can localize this effect to inside C<eval> bodies if this is desireable:
199For example:
200
201 eval {
202 local $CGI::Carp::TO_BROWSER = 0;
203 die "Fatal error messages not sent browser"
204 }
205 # $@ will contain error message
206
207
208=head1 MAKING WARNINGS APPEAR AS HTML COMMENTS
209
210It is now also possible to make non-fatal errors appear as HTML
211comments embedded in the output of your program. To enable this
212feature, export the new "warningsToBrowser" subroutine. Since sending
213warnings to the browser before the HTTP headers have been sent would
214cause an error, any warnings are stored in an internal buffer until
215you call the warningsToBrowser() subroutine with a true argument:
216
217 use CGI::Carp qw(fatalsToBrowser warningsToBrowser);
218 use CGI qw(:standard);
219 print header();
220 warningsToBrowser(1);
221
222You may also give a false argument to warningsToBrowser() to prevent
223warnings from being sent to the browser while you are printing some
224content where HTML comments are not allowed:
225
226 warningsToBrowser(0); # disable warnings
227 print "<script type=\"text/javascript\"><!--\n";
228 print_some_javascript_code();
229 print "//--></script>\n";
230 warningsToBrowser(1); # re-enable warnings
231
232Note: In this respect warningsToBrowser() differs fundamentally from
233fatalsToBrowser(), which you should never call yourself!
234
235=head1 OVERRIDING THE NAME OF THE PROGRAM
236
237CGI::Carp includes the name of the program that generated the error or
238warning in the messages written to the log and the browser window.
239Sometimes, Perl can get confused about what the actual name of the
240executed program was. In these cases, you can override the program
241name that CGI::Carp will use for all messages.
242
243The quick way to do that is to tell CGI::Carp the name of the program
244in its use statement. You can do that by adding
245"name=cgi_carp_log_name" to your "use" statement. For example:
246
247 use CGI::Carp qw(name=cgi_carp_log_name);
248
249. If you want to change the program name partway through the program,
250you can use the C<set_progname()> function instead. It is not
251exported by default, you must import it explicitly by saying
252
253 use CGI::Carp qw(set_progname);
254
255Once you've done that, you can change the logged name of the program
256at any time by calling
257
258 set_progname(new_program_name);
259
260You can set the program back to the default by calling
261
262 set_progname(undef);
263
264Note that this override doesn't happen until after the program has
265compiled, so any compile-time errors will still show up with the
266non-overridden program name
267
268=head1 CHANGE LOG
269
2703.51 Added $CGI::Carp::TO_BROWSER
271
2721.29 Patch from Peter Whaite to fix the unfixable problem of CGI::Carp
273 not behaving correctly in an eval() context.
274
2751.05 carpout() added and minor corrections by Marc Hedlund
276 <hedlund@best.com> on 11/26/95.
277
2781.06 fatalsToBrowser() no longer aborts for fatal errors within
279 eval() statements.
280
2811.08 set_message() added and carpout() expanded to allow for FileHandle
282 objects.
283
2841.09 set_message() now allows users to pass a code REFERENCE for
285 really custom error messages. croak and carp are now
286 exported by default. Thanks to Gunther Birznieks for the
287 patches.
288
2891.10 Patch from Chris Dean (ctdean@cogit.com) to allow
290 module to run correctly under mod_perl.
291
2921.11 Changed order of &gt; and &lt; escapes.
293
2941.12 Changed die() on line 217 to CORE::die to avoid B<-w> warning.
295
2961.13 Added cluck() to make the module orthogonal with Carp.
297 More mod_perl related fixes.
298
2991.20 Patch from Ilmari Karonen (perl@itz.pp.sci.fi): Added
300 warningsToBrowser(). Replaced <CODE> tags with <PRE> in
301 fatalsToBrowser() output.
302
3031.23 ineval() now checks both $^S and inspects the message for the "eval" pattern
304 (hack alert!) in order to accommodate various combinations of Perl and
305 mod_perl.
306
3071.24 Patch from Scott Gifford (sgifford@suspectclass.com): Add support
308 for overriding program name.
309
3101.26 Replaced CORE::GLOBAL::die with the evil $SIG{__DIE__} because the
311 former isn't working in some people's hands. There is no such thing
312 as reliable exception handling in Perl.
313
3141.27 Replaced tell STDOUT with bytes=tell STDOUT.
315
316=head1 AUTHORS
317
318Copyright 1995-2002, Lincoln D. Stein. All rights reserved.
319
320This library is free software; you can redistribute it and/or modify
321it under the same terms as Perl itself.
322
323Address bug reports and comments to: lstein@cshl.org
324
325=head1 SEE ALSO
326
327Carp, CGI::Base, CGI::BasePlus, CGI::Request, CGI::MiniSvr, CGI::Form,
328CGI::Response
329
330=cut
331
332118µsrequire 5.000;
33321.07ms21.20ms
# spent 1.13ms (1.06+66µs) within CGI::Carp::BEGIN@333 which was called: # once (1.06ms+66µs) by main::BEGIN@11 at line 333
use Exporter;
# spent 1.13ms making 1 call to CGI::Carp::BEGIN@333 # spent 66µs making 1 call to Exporter::import
334#use Carp;
335
# spent 3.37ms (3.14+230µs) within CGI::Carp::BEGIN@335 which was called: # once (3.14ms+230µs) by main::BEGIN@11 at line 338
BEGIN {
3361114µs require Carp;
337122µs *CORE::GLOBAL::die = \&CGI::Carp::die;
338132µs13.37ms}
# spent 3.37ms making 1 call to CGI::Carp::BEGIN@335
339
34022.64ms110µs
# spent 10µs within CGI::Carp::BEGIN@340 which was called: # once (10µs+0s) by main::BEGIN@11 at line 340
use File::Spec;
# spent 10µs making 1 call to CGI::Carp::BEGIN@340
341
34218µs@ISA = qw(Exporter);
34312µs@EXPORT = qw(confess croak carp);
34413µs@EXPORT_OK = qw(carpout fatalsToBrowser warningsToBrowser wrap set_message set_die_handler set_progname cluck ^name= die);
345
34614µs$main::SIG{__WARN__}=\&CGI::Carp::warn;
347
34812µs$CGI::Carp::VERSION = '3.51';
34911µs$CGI::Carp::CUSTOM_MSG = undef;
35011µs$CGI::Carp::DIE_HANDLER = undef;
35111µs$CGI::Carp::TO_BROWSER = 1;
352
353
354# fancy import routine detects and handles 'errorWrap' specially.
355
# spent 258µs (55+204) within CGI::Carp::import which was called: # once (55µs+204µs) by main::BEGIN@11 at line 11 of view
sub import {
35612µs my $pkg = shift;
35711µs my(%routines);
35811µs my(@name);
359119µs13µs if (@name=grep(/^name=/,@_))
# spent 3µs making 1 call to CGI::Carp::CORE:match
360 {
361 my($n) = (split(/=/,$name[0]))[1];
362 set_progname($n);
363 @_=grep(!/^name=/,@_);
364 }
365
36614µs grep($routines{$_}++,@_,@EXPORT);
36712µs $WRAP++ if $routines{'fatalsToBrowser'} || $routines{'wrap'};
36811µs $WARN++ if $routines{'warningsToBrowser'};
36912µs my($oldlevel) = $Exporter::ExportLevel;
37011µs $Exporter::ExportLevel = 1;
37118µs1201µs Exporter::import($pkg,keys %routines);
# spent 201µs making 1 call to Exporter::import
37211µs $Exporter::ExportLevel = $oldlevel;
373114µs $main::SIG{__DIE__} =\&CGI::Carp::die if $routines{'fatalsToBrowser'};
374# $pkg->export('CORE::GLOBAL','die');
375}
376
377# These are the originals
378sub realwarn { CORE::warn(@_); }
379sub realdie { CORE::die(@_); }
380
381sub id {
382 my $level = shift;
383 my($pack,$file,$line,$sub) = caller($level);
384 my($dev,$dirs,$id) = File::Spec->splitpath($file);
385 return ($file,$line,$id);
386}
387
388sub stamp {
389 my $time = scalar(localtime);
390 my $frame = 0;
391 my ($id,$pack,$file,$dev,$dirs);
392 if (defined($CGI::Carp::PROGNAME)) {
393 $id = $CGI::Carp::PROGNAME;
394 } else {
395 do {
396 $id = $file;
397 ($pack,$file) = caller($frame++);
398 } until !$file;
399 }
400 ($dev,$dirs,$id) = File::Spec->splitpath($id);
401 return "[$time] $id: ";
402}
403
404sub set_progname {
405 $CGI::Carp::PROGNAME = shift;
406 return $CGI::Carp::PROGNAME;
407}
408
409
410sub warn {
411 my $message = shift;
412 my($file,$line,$id) = id(1);
413 $message .= " at $file line $line.\n" unless $message=~/\n$/;
414 _warn($message) if $WARN;
415 my $stamp = stamp;
416 $message=~s/^/$stamp/gm;
417 realwarn $message;
418}
419
420sub _warn {
421 my $msg = shift;
422 if ($EMIT_WARNINGS) {
423 # We need to mangle the message a bit to make it a valid HTML
424 # comment. This is done by substituting similar-looking ISO
425 # 8859-1 characters for <, > and -. This is a hack.
426 $msg =~ tr/<>-/\253\273\255/;
427 chomp $msg;
428 print STDOUT "<!-- warning: $msg -->\n";
429 } else {
430 push @WARNINGS, $msg;
431 }
432}
433
434
435# The mod_perl package Apache::Registry loads CGI programs by calling
436# eval. These evals don't count when looking at the stack backtrace.
437sub _longmess {
438 my $message = Carp::longmess();
439 $message =~ s,eval[^\n]+(ModPerl|Apache)/(?:Registry|Dispatch)\w*\.pm.*,,s
440 if exists $ENV{MOD_PERL};
441 return $message;
442}
443
444sub ineval {
445 (exists $ENV{MOD_PERL} ? 0 : $^S) || _longmess() =~ /eval [\{\']/m
446}
447
448sub die {
449 # if no argument is passed, propagate $@ like
450 # the real die
451 my ($arg,@rest) = @_ ? @_
452 : $@ ? "$@\t...propagated"
453 : "Died"
454 ;
455
456 &$DIE_HANDLER($arg,@rest) if $DIE_HANDLER;
457
458 # the "$arg" is done on purpose!
459 # if called as die( $object, 'string' ),
460 # all is stringified, just like with
461 # the real 'die'
462 $arg = join '' => "$arg", @rest if @rest;
463
464 my($file,$line,$id) = id(1);
465
466 $arg .= " at $file line $line.\n" unless ref $arg or $arg=~/\n$/;
467
468 realdie $arg if ineval();
469 &fatalsToBrowser($arg) if ($WRAP and $CGI::Carp::TO_BROWSER);
470
471 $arg=~s/^/ stamp() /gme if $arg =~ /\n$/ or not exists $ENV{MOD_PERL};
472
473 $arg .= "\n" unless $arg =~ /\n$/;
474
475 realdie $arg;
476}
477
478sub set_message {
479 $CGI::Carp::CUSTOM_MSG = shift;
480 return $CGI::Carp::CUSTOM_MSG;
481}
482
483sub set_die_handler {
484
485 my ($handler) = shift;
486
487 #setting SIG{__DIE__} here is necessary to catch runtime
488 #errors which are not called by literally saying "die",
489 #such as the line "undef->explode();". however, doing this
490 #will interfere with fatalsToBrowser, which also sets
491 #SIG{__DIE__} in the import() function above (or the
492 #import() function above may interfere with this). for
493 #this reason, you should choose to either set the die
494 #handler here, or use fatalsToBrowser, not both.
495 $main::SIG{__DIE__} = $handler;
496
497 $CGI::Carp::DIE_HANDLER = $handler;
498
499 return $CGI::Carp::DIE_HANDLER;
500}
501
502sub confess { CGI::Carp::die Carp::longmess @_; }
503sub croak { CGI::Carp::die Carp::shortmess @_; }
504sub carp { CGI::Carp::warn Carp::shortmess @_; }
505sub cluck { CGI::Carp::warn Carp::longmess @_; }
506
507# We have to be ready to accept a filehandle as a reference
508# or a string.
509sub carpout {
510 my($in) = @_;
511 my($no) = fileno(to_filehandle($in));
512 realdie("Invalid filehandle $in\n") unless defined $no;
513
514 open(SAVEERR, ">&STDERR");
515 open(STDERR, ">&$no") or
516 ( print SAVEERR "Unable to redirect STDERR: $!\n" and exit(1) );
517}
518
519sub warningsToBrowser {
520 $EMIT_WARNINGS = @_ ? shift : 1;
521 _warn(shift @WARNINGS) while $EMIT_WARNINGS and @WARNINGS;
522}
523
524# headers
525sub fatalsToBrowser {
526 my $msg = shift;
527
528 $msg = "$msg" if ref $msg;
529
530 $msg=~s/&/&amp;/g;
531 $msg=~s/>/&gt;/g;
532 $msg=~s/</&lt;/g;
533 $msg=~s/"/&quot;/g;
534
535 my($wm) = $ENV{SERVER_ADMIN} ?
536 qq[the webmaster (<a href="mailto:$ENV{SERVER_ADMIN}">$ENV{SERVER_ADMIN}</a>)] :
537 "this site's webmaster";
538 my ($outer_message) = <<END;
539For help, please send mail to $wm, giving this error message
540and the time and date of the error.
541END
542 ;
543 my $mod_perl = exists $ENV{MOD_PERL};
544
545 if ($CUSTOM_MSG) {
546 if (ref($CUSTOM_MSG) eq 'CODE') {
547 print STDOUT "Content-type: text/html\n\n"
548 unless $mod_perl;
549 eval {
550 &$CUSTOM_MSG($msg); # nicer to perl 5.003 users
551 };
552 if ($@) { print STDERR q(error while executing the error handler: $@); }
553
554 return;
555 } else {
556 $outer_message = $CUSTOM_MSG;
557 }
558 }
559
560 my $mess = <<END;
561<h1>Software error:</h1>
562<pre>$msg</pre>
563<p>
564$outer_message
565</p>
566END
567 ;
568
569 if ($mod_perl) {
570 my $r;
571 if ($ENV{MOD_PERL_API_VERSION} && $ENV{MOD_PERL_API_VERSION} == 2) {
572 $mod_perl = 2;
573 require Apache2::RequestRec;
574 require Apache2::RequestIO;
575 require Apache2::RequestUtil;
576 require APR::Pool;
577 require ModPerl::Util;
578 require Apache2::Response;
579 $r = Apache2::RequestUtil->request;
580 }
581 else {
582 $r = Apache->request;
583 }
584 # If bytes have already been sent, then
585 # we print the message out directly.
586 # Otherwise we make a custom error
587 # handler to produce the doc for us.
588 if ($r->bytes_sent) {
589 $r->print($mess);
590 $mod_perl == 2 ? ModPerl::Util::exit(0) : $r->exit;
591 } else {
592 # MSIE won't display a custom 500 response unless it is >512 bytes!
593 if ($ENV{HTTP_USER_AGENT} =~ /MSIE/) {
594 $mess = "<!-- " . (' ' x 513) . " -->\n$mess";
595 }
596 $r->custom_response(500,$mess);
597 }
598 } else {
599 my $bytes_written = eval{tell STDOUT};
600 if (defined $bytes_written && $bytes_written > 0) {
601 print STDOUT $mess;
602 }
603 else {
604 print STDOUT "Status: 500\n";
605 print STDOUT "Content-type: text/html\n\n";
606 print STDOUT $mess;
607 }
608 }
609
610 warningsToBrowser(1); # emit warnings before dying
611}
612
613# Cut and paste from CGI.pm so that we don't have the overhead of
614# always loading the entire CGI module.
615sub to_filehandle {
616 my $thingy = shift;
617 return undef unless $thingy;
618 return $thingy if UNIVERSAL::isa($thingy,'GLOB');
619 return $thingy if UNIVERSAL::isa($thingy,'FileHandle');
620 if (!ref($thingy)) {
621 my $caller = 1;
622 while (my $package = caller($caller++)) {
623 my($tmp) = $thingy=~/[\':]/ ? $thingy : "$package\:\:$thingy";
624 return $tmp if defined(fileno($tmp));
625 }
626 }
627 return undef;
628}
629
630113µs1;
 
# spent 3µs within CGI::Carp::CORE:match which was called: # once (3µs+0s) by CGI::Carp::import at line 359
sub CGI::Carp::CORE:match; # opcode