line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Sub::Exception; |
2
|
1
|
|
|
1
|
|
23610
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
41
|
|
3
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
173
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub import { |
8
|
1
|
|
|
1
|
|
15
|
my ($class, %args) = @_; |
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
|
|
3
|
my $caller = caller; |
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
|
|
7
|
while (my ($fn, $handler) = each %args) { |
13
|
2
|
|
|
|
|
8
|
$class->export( |
14
|
|
|
|
|
|
|
name => $fn, |
15
|
|
|
|
|
|
|
error_handler => $handler, |
16
|
|
|
|
|
|
|
package => $caller, |
17
|
|
|
|
|
|
|
); |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub export { |
22
|
2
|
|
|
2
|
1
|
7
|
my ($class, %args) = @_; |
23
|
|
|
|
|
|
|
|
24
|
2
|
|
|
|
|
3
|
my $name = $args{name}; |
25
|
2
|
|
|
|
|
5
|
my $error_handler = $args{error_handler}, |
26
|
|
|
|
|
|
|
my $pkg = $args{package}; |
27
|
|
|
|
|
|
|
|
28
|
1
|
|
|
1
|
|
7
|
no strict 'refs'; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
178
|
|
29
|
2
|
|
|
|
|
2610
|
*{"$pkg\::$name"} = sub (&) { |
30
|
2
|
|
|
2
|
|
569
|
my ($sub) = @_; |
31
|
|
|
|
|
|
|
|
32
|
2
|
|
|
|
|
3
|
eval { |
33
|
2
|
|
|
|
|
7
|
$sub->(); |
34
|
|
|
|
|
|
|
}; |
35
|
2
|
50
|
|
|
|
23
|
if ($@) { |
36
|
2
|
|
|
|
|
10
|
$error_handler->($_ = $@); |
37
|
|
|
|
|
|
|
} |
38
|
2
|
|
|
|
|
9
|
}; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
1; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
__END__ |