line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package pluskeys; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
29051
|
use strict; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
55
|
|
4
|
2
|
|
|
2
|
|
8
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
41
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
8
|
use Carp; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
252
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our($VERSION) = q($Revision: 2.3 $) =~ / \b ( \d+ (?: \. \d+ )+ ) \b /x; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
my $My_Package = __PACKAGE__; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub import { |
13
|
4
|
|
|
4
|
|
2611
|
shift; # discard "pluskeys" invocant |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
################################################################# |
16
|
|
|
|
|
|
|
# Create named constants in caller's package so they |
17
|
|
|
|
|
|
|
# can be used to access munged member names with +NAME |
18
|
|
|
|
|
|
|
# which both catches typos and adds package-name munging so |
19
|
|
|
|
|
|
|
# that more than one class in a hierarchy can have a key |
20
|
|
|
|
|
|
|
# with the same name. |
21
|
|
|
|
|
|
|
# |
22
|
|
|
|
|
|
|
# Must be called from a BEGIN block to do any good. That's |
23
|
|
|
|
|
|
|
# why it is a use statement, since that has a BEGIN blocked |
24
|
|
|
|
|
|
|
# wrapped around it. |
25
|
|
|
|
|
|
|
################################################################# |
26
|
|
|
|
|
|
|
|
27
|
4
|
|
|
|
|
18
|
for my $member (@_) { |
28
|
|
|
|
|
|
|
# Has to start with a letter or an underscore, and be one |
29
|
|
|
|
|
|
|
# or more identifier characters long and nothing else. |
30
|
2
|
50
|
|
2
|
|
896
|
$member =~ / ^ (?= [\p{Letter}_] ) \w+ $ /x |
|
2
|
|
|
|
|
174
|
|
|
2
|
|
|
|
|
20
|
|
|
5
|
|
|
|
|
21
|
|
31
|
|
|
|
|
|
|
|| croak "Bad pluskey: '$member' is not a valid identifier"; |
32
|
|
|
|
|
|
|
|
33
|
5
|
|
|
|
|
10
|
my $his_package = caller; |
34
|
|
|
|
|
|
|
|
35
|
5
|
50
|
|
1
|
|
292
|
eval <<"MAKE_A_MEMBER_CONSTANT" || croak "member init of $member failed: $@"; |
|
1
|
|
|
1
|
|
6
|
|
|
1
|
|
|
1
|
|
1
|
|
|
1
|
|
|
1
|
|
2
|
|
|
1
|
|
|
1
|
|
10
|
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
0
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
3
|
|
36
|
|
|
|
|
|
|
package $his_package; |
37
|
|
|
|
|
|
|
use constant $member => ${My_Package}::_mk_safe_member('$member'); |
38
|
|
|
|
|
|
|
1; |
39
|
|
|
|
|
|
|
MAKE_A_MEMBER_CONSTANT |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub _mk_safe_member($) { |
44
|
5
|
|
|
5
|
|
5
|
my($member_name) = @_; |
45
|
5
|
|
|
|
|
6
|
my $his_package = caller; |
46
|
5
|
|
|
|
|
255
|
return $his_package . "::" . $member_name; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
1; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
__END__ |