Leser: 2
6 Einträge, 1 Seite |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package Handler;
use strict;
use warnings;
use Fcntl qw(:DEFAULT :flock);
use IO::Handle;
use Data::Dumper;
my $opts = {
filename => './foo.bar',
mode => O_WRONLY | O_APPEND | O_CREAT,
umask => 0640,
};
my $self = bless $opts, __PACKAGE__;
open my $olderr, ">&STDERR" or die $!;
$self->{olderr} = \$olderr;
sysopen(STDERR, $self->{filename}, $self->{mode}, $self->{umask}) or die $!;
$self->{fh} = \*STDERR;
$self->{olddie} = $SIG{__DIE__};
$SIG{__DIE__} = \&_die_handler("bar foo");
STDERR->autoflush(1);
sub _die_handler {
print {$self->{fh}} Dumper(\@_);
exit(9);
}
1;
die "foo bar";
1
2
3
4
5
6
$SIG{__DIE__} = \&_die_handler("bar foo");
...
sub _die_handler {
print {$self->{fh}} Dumper(\@_);
exit(9);
}
1
2
3
4
5
6
7
8
9
10
#!/usr/bin/perl
use strict;
use warnings;
my $sample = \&test();
sub test{
print "Hallo\n";
}
6 Einträge, 1 Seite |