line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Unwind::Protect; |
2
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
3
|
|
|
|
|
|
|
|
4
|
2
|
|
|
2
|
|
63807
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
91
|
|
5
|
2
|
|
|
2
|
|
12
|
use warnings; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
62
|
|
6
|
2
|
|
|
2
|
|
2056
|
use Sub::Uplevel; |
|
2
|
|
|
|
|
2708
|
|
|
2
|
|
|
|
|
12
|
|
7
|
2
|
|
|
|
|
27
|
use Sub::Exporter -setup => { |
8
|
|
|
|
|
|
|
exports => ['unwind_protect'], |
9
|
|
|
|
|
|
|
groups => { |
10
|
|
|
|
|
|
|
default => ['unwind_protect'], |
11
|
|
|
|
|
|
|
}, |
12
|
2
|
|
|
2
|
|
2142
|
}; |
|
2
|
|
|
|
|
34341
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub unwind_protect (&@) { |
15
|
5
|
|
|
5
|
1
|
4477
|
my $code = shift; |
16
|
5
|
|
|
|
|
17
|
my %args = @_; |
17
|
|
|
|
|
|
|
|
18
|
5
|
|
|
|
|
11
|
my $wantarray = wantarray; |
19
|
|
|
|
|
|
|
|
20
|
5
|
|
|
|
|
6
|
my @ret; |
21
|
|
|
|
|
|
|
|
22
|
5
|
|
|
|
|
8
|
eval { |
23
|
5
|
100
|
|
|
|
21
|
if ($wantarray) { |
|
|
100
|
|
|
|
|
|
24
|
1
|
|
|
|
|
4
|
@ret = uplevel 1, $code; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
elsif (defined $wantarray) { |
27
|
2
|
|
|
|
|
10
|
$ret[0] = uplevel 1, $code; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
else { |
30
|
2
|
|
|
|
|
10
|
uplevel 1, $code; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
}; |
33
|
|
|
|
|
|
|
|
34
|
5
|
|
|
|
|
258
|
my $exception = $@; |
35
|
|
|
|
|
|
|
|
36
|
5
|
50
|
|
|
|
25
|
$args{after}->() if $args{after}; |
37
|
|
|
|
|
|
|
|
38
|
5
|
100
|
|
|
|
24
|
if ($exception) { |
39
|
2
|
|
|
|
|
11
|
local $SIG{__DIE__}; |
40
|
2
|
|
|
|
|
19
|
die $exception; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
3
|
100
|
|
|
|
9
|
return @ret if $wantarray; |
44
|
2
|
50
|
|
|
|
10
|
return $ret[0] if defined $wantarray; |
45
|
0
|
|
|
|
|
|
return 0; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
1; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
__END__ |