| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Sub::Lib; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
12682
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
22
|
|
|
4
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
267
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub new { |
|
9
|
5
|
|
|
5
|
1
|
1612
|
my ($class, @args) = @_; |
|
10
|
|
|
|
|
|
|
|
|
11
|
5
|
|
|
|
|
6
|
my $args; |
|
12
|
5
|
100
|
|
|
|
8
|
if(1 == @args) { |
|
13
|
2
|
100
|
|
|
|
9
|
die "reference argument to new() must be a HASH\n" |
|
14
|
|
|
|
|
|
|
unless 'HASH' eq ref $args[0]; |
|
15
|
1
|
|
|
|
|
2
|
$args = $args[0]; |
|
16
|
|
|
|
|
|
|
} |
|
17
|
|
|
|
|
|
|
else { |
|
18
|
3
|
100
|
|
|
|
10
|
die "non-reference argument list to new() must have an even number of elements\n" |
|
19
|
|
|
|
|
|
|
unless 0 == @args % 2; |
|
20
|
2
|
|
|
|
|
4
|
$args = {@args}; |
|
21
|
|
|
|
|
|
|
} |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# \o/ Lobe den Abgrund |
|
24
|
3
|
|
|
|
|
4
|
my $self = bless do { |
|
25
|
3
|
|
|
|
|
2
|
my $_lib = { }; |
|
26
|
|
|
|
|
|
|
sub { |
|
27
|
10
|
|
|
10
|
|
975
|
my ($name, $sub) = @_; |
|
28
|
|
|
|
|
|
|
|
|
29
|
10
|
100
|
|
|
|
19
|
return $_lib |
|
30
|
|
|
|
|
|
|
unless defined $name; |
|
31
|
|
|
|
|
|
|
|
|
32
|
7
|
100
|
|
|
|
12
|
if(defined $sub) { |
|
33
|
3
|
100
|
|
|
|
12
|
die "sub-routine ($name) is not a sub-routine?\n" |
|
34
|
|
|
|
|
|
|
unless 'CODE' eq ref $sub; |
|
35
|
|
|
|
|
|
|
die "sub-routine ($name) already installed in library\n" |
|
36
|
2
|
100
|
|
|
|
8
|
if exists $_lib->{$name}; |
|
37
|
|
|
|
|
|
|
|
|
38
|
1
|
|
|
|
|
1
|
$_lib->{$name} = $sub; |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
else { |
|
41
|
|
|
|
|
|
|
die "sub-routine ($name) not installed in library\n" |
|
42
|
4
|
100
|
|
|
|
12
|
unless exists $_lib->{$name}; |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
|
|
45
|
4
|
|
|
|
|
7
|
return $_lib->{$name}; |
|
46
|
|
|
|
|
|
|
} |
|
47
|
3
|
|
|
|
|
12
|
}, $class; |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
$self->($_, $args->{$_}) |
|
50
|
3
|
|
|
|
|
9
|
for keys %$args; |
|
51
|
2
|
|
|
|
|
3
|
return $self; |
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub has { |
|
55
|
2
|
|
|
2
|
1
|
5
|
my ($self, $name) = @_; |
|
56
|
|
|
|
|
|
|
|
|
57
|
2
|
|
|
|
|
3
|
my $_lib = $self->(); |
|
58
|
2
|
|
|
|
|
6
|
return $_lib->{$name}; |
|
59
|
|
|
|
|
|
|
} |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub run { |
|
62
|
1
|
|
|
1
|
1
|
243
|
my ($self, $name, @args) = @_; |
|
63
|
|
|
|
|
|
|
|
|
64
|
1
|
|
|
|
|
3
|
return $self->($name)->(@args); |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub call { |
|
68
|
1
|
|
|
1
|
1
|
239
|
my ($self, $name, $object, @args) = @_; |
|
69
|
|
|
|
|
|
|
|
|
70
|
1
|
|
|
|
|
3
|
my $sub = $self->($name); |
|
71
|
1
|
|
|
|
|
2
|
return $object->$sub(@args); |
|
72
|
|
|
|
|
|
|
} |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
1 |
|
75
|
|
|
|
|
|
|
__END__ |