line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Const::Common; |
2
|
3
|
|
|
3
|
|
56508
|
use 5.008005; |
|
3
|
|
|
|
|
11
|
|
|
3
|
|
|
|
|
133
|
|
3
|
3
|
|
|
3
|
|
17
|
use strict; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
98
|
|
4
|
3
|
|
|
3
|
|
25
|
use warnings; |
|
3
|
|
|
|
|
10
|
|
|
3
|
|
|
|
|
181
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = "0.01"; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
require Exporter; |
9
|
3
|
|
|
3
|
|
2439
|
use Data::Lock; |
|
3
|
|
|
|
|
28821
|
|
|
3
|
|
|
|
|
310
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub import { |
12
|
4
|
|
|
4
|
|
109
|
my $pkg = caller; |
13
|
4
|
|
|
|
|
7
|
shift; |
14
|
4
|
50
|
|
|
|
26
|
my %constants = @_ == 1 ? %{ $_[0] } : @_; |
|
0
|
|
|
|
|
0
|
|
15
|
|
|
|
|
|
|
|
16
|
4
|
|
|
|
|
18
|
Data::Lock::dlock my $locked = \%constants; |
17
|
|
|
|
|
|
|
{ |
18
|
3
|
|
|
3
|
|
28
|
no strict 'refs'; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
632
|
|
|
4
|
|
|
|
|
135
|
|
19
|
4
|
|
|
|
|
5
|
${ "$pkg\::_constants" } = $locked; |
|
4
|
|
|
|
|
39
|
|
20
|
4
|
|
|
|
|
7
|
for my $method (qw/const constants constant_names/) { |
21
|
12
|
|
|
|
|
19
|
*{ "$pkg\::$method" } = \&{ __PACKAGE__ . "::$method" }; |
|
12
|
|
|
|
|
49
|
|
|
12
|
|
|
|
|
32
|
|
22
|
|
|
|
|
|
|
} |
23
|
4
|
|
|
|
|
8
|
push @{"$pkg\::ISA"}, ('Exporter'); |
|
4
|
|
|
|
|
37
|
|
24
|
4
|
|
|
|
|
7
|
push @{"$pkg\::EXPORT"}, (keys %$locked); |
|
4
|
|
|
|
|
23
|
|
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
4
|
|
|
|
|
21
|
require constant; |
28
|
4
|
|
|
|
|
11
|
@_ = ('constant', $locked); |
29
|
4
|
|
|
|
|
344
|
goto constant->can('import'); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub const { |
33
|
2
|
|
|
2
|
1
|
3005
|
my ($pkg, $constant_name) = @_; |
34
|
2
|
|
|
|
|
8
|
$pkg->constants->{$constant_name}; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub constants { |
38
|
3
|
|
|
3
|
|
17
|
no strict 'refs'; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
293
|
|
39
|
4
|
|
|
4
|
1
|
65
|
my $pkg = shift; |
40
|
4
|
|
|
|
|
5
|
${ "$pkg\::_constants" }; |
|
4
|
|
|
|
|
39
|
|
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub constant_names { |
44
|
1
|
|
|
1
|
1
|
3
|
my $pkg = shift; |
45
|
1
|
|
|
|
|
2
|
sort keys %{ $pkg->constants }; |
|
1
|
|
|
|
|
3
|
|
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
1; |
49
|
|
|
|
|
|
|
__END__ |