For some reason, I cannot stand to see it not written as
BEGIN {
use CGI::Carp qw(carpout);
carpout(\*LOGGY) if open(LOGGY,'>>'.__FILE__.'.err.log');
}
I just felt I had to share that.
update: weeeel, S_Shrum, i'd either carpout(\*STDOUT); or make warnings fatal and stick with fatalsToBrowser, like (and this works a little weird)
#!/usr/bin/perl
use warnings FATAL => qw( all );
warn "hello there";
{ # line 4 (notice its in a block)
BAREWORD;
BAREWORD;
BAREWORD;
}
or more portable (warnings pragma ain't available everywhere)
#!/usr/bin/perl
$SIG{__WARN__} = sub {die("warning: ",@_)};
warn "hello";
__END__
or better yet
#!/usr/bin/perl
use CGI::Carp qw( fatalsToBrowser );
use Fatal qw( warn );
use strict;
use warnings;
warn "hello";
and maybe
BEGIN {
use vars qw( $WARR );
$SIG{__WARN__} = sub {
$WARR .= join ' ',(@_),caller(),"\n";
};
}
warn "hello";
warn "hooyah";
die "aaah";
# ...
END {
print "Content-Type: text-html\r\n\r\n <pre> $WARR </pre>";
}
Reccomended reading is warnings,
perllexwarn, sigtrap, Perl's Warn and Die Signals.
|