#!/usr/bin/perl -w
$| = 1;
use strict;
use warnings;
use Fcntl qw(:DEFAULT :flock);
my %env = (
chmod_dateien => 0666,
);
print "Content-Type: text/html\n\nHallo!
";
my @errorstack;
local $SIG{__WARN__} = sub {
(my $error = shift) =~ s/[\r\n]//g;
push @errorstack,$error;
sysopen (my $errorlog,'errorlog.txt',O_WRONLY|O_APPEND|O_CREAT,$env{chmod_dateien});
if ($! eq '') {
print $errorlog '[' . localtime() . '] [error] [client ' . (defined $ENV{'REMOTE_ADDR'} ? $ENV{'REMOTE_ADDR'} : 'n.a.') . '] ' . $error . "\n";
close $errorlog;
}
};
print "Vorher: @errorstack
\n";
require 'test2.pl';
&fehlersub ('foo');
print "Nachher: @errorstack
\n";