line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package slot;
|
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
sub KM() {4}
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Tie::Hash::KeysMask;
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
22750
|
use 5.008007;
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
58
|
|
8
|
|
|
|
|
|
|
our $VERSION = 0.01;
|
9
|
1
|
|
|
1
|
|
8
|
use strict;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
39
|
|
10
|
|
|
|
|
|
|
#no strict 'subs';
|
11
|
1
|
|
|
1
|
|
16
|
no strict 'refs';
|
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
40
|
|
12
|
1
|
|
|
1
|
|
6
|
use Carp;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
122
|
|
13
|
|
|
|
|
|
|
our @ISA;
|
14
|
1
|
|
|
1
|
|
7
|
use base ('Tie::Hash::Create');
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
878
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub codemap
|
17
|
|
|
|
|
|
|
{
|
18
|
|
|
|
|
|
|
my $class = shift;
|
19
|
|
|
|
|
|
|
croak 'codemap not for object!' if ref($class);
|
20
|
|
|
|
|
|
|
croak 'missing argument' unless @_;
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
my $mf = shift;
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
return $mf if ref($mf) eq 'CODE';
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
if ( ref($mf) eq 'HASH' )
|
27
|
|
|
|
|
|
|
{
|
28
|
|
|
|
|
|
|
my $transl = $mf;
|
29
|
|
|
|
|
|
|
$mf = sub { exists $transl->{$_[0]} ? $transl->{$_[0]} : $_[0];} ;
|
30
|
|
|
|
|
|
|
}
|
31
|
|
|
|
|
|
|
else
|
32
|
|
|
|
|
|
|
{
|
33
|
|
|
|
|
|
|
$mf = { 'lc'=> sub {lc $_[0]}, 'uc'=> sub {uc $_[0]} }->{$mf} ;
|
34
|
|
|
|
|
|
|
};
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
$mf;
|
37
|
|
|
|
|
|
|
}
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
#use Trace::Caller ':all';
|
40
|
|
|
|
|
|
|
#use Data::Dumper;
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub TIEHASH
|
43
|
|
|
|
|
|
|
{
|
44
|
|
|
|
|
|
|
my ($class,$mf) = splice @_,0,2;
|
45
|
|
|
|
|
|
|
$mf = codemap($class,$mf);
|
46
|
|
|
|
|
|
|
#$mf = preamb::codemap $mf;
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
croak 'Parameter of type CODE or NULL required here!'
|
49
|
|
|
|
|
|
|
unless $mf && (ref($mf) eq 'CODE');
|
50
|
|
|
|
|
|
|
# structure of the created object (the one also accessed by tied(%array))
|
51
|
|
|
|
|
|
|
# ----------------------------------------------------------------------
|
52
|
|
|
|
|
|
|
# ARRAY Contents e.g.
|
53
|
|
|
|
|
|
|
# ----------------------------------------------------------------------
|
54
|
|
|
|
|
|
|
# 0 internal reference to the tied hash generated by tie
|
55
|
|
|
|
|
|
|
# 1 real reference to the tied hash \%H
|
56
|
|
|
|
|
|
|
# 2 status flag. reserved for planned subclass. 0
|
57
|
|
|
|
|
|
|
# 3 slot for default values. used by subclass. [...,Name=>Value,...]
|
58
|
|
|
|
|
|
|
# 4 CODE the keymask function sub {...}
|
59
|
|
|
|
|
|
|
# 5 fixed arguments for call of the keymask function
|
60
|
|
|
|
|
|
|
# 6> free
|
61
|
|
|
|
|
|
|
# ----------------------------------------------------------------------
|
62
|
|
|
|
|
|
|
# loc. 0 1 2 3 4 #| 2:defaults | 3:&mask | 4:fix arguments to mask
|
63
|
|
|
|
|
|
|
bless [{},undef,0,undef, $mf, [@_]], $class;
|
64
|
|
|
|
|
|
|
}
|
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub transKey
|
67
|
|
|
|
|
|
|
{
|
68
|
|
|
|
|
|
|
#print Dumper[$_[0]];
|
69
|
|
|
|
|
|
|
#printf 'transkey uses (%d) %s%s',slot::KM,ref($_[0][slot::KM]),qq(\n);
|
70
|
|
|
|
|
|
|
$_[0][slot::KM]? $_[0][slot::KM]->($_[1],@{$_[0][slot::KM+1]}): $_[1];
|
71
|
|
|
|
|
|
|
}
|
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub STORE
|
74
|
|
|
|
|
|
|
{
|
75
|
|
|
|
|
|
|
$_[0][0]{transKey @_} = $_[2];
|
76
|
|
|
|
|
|
|
}
|
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub FETCH
|
79
|
|
|
|
|
|
|
{
|
80
|
|
|
|
|
|
|
$_[0][0]{transKey @_};
|
81
|
|
|
|
|
|
|
}
|
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub DELETE
|
84
|
|
|
|
|
|
|
{
|
85
|
|
|
|
|
|
|
delete $_[0][0]{transKey @_};
|
86
|
|
|
|
|
|
|
}
|
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub EXISTS
|
89
|
|
|
|
|
|
|
{
|
90
|
|
|
|
|
|
|
exists $_[0][0]{transKey @_};
|
91
|
|
|
|
|
|
|
}
|
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
1;
|
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
__END__
|