line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Tie::Alias; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
34731
|
use 5.008; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
40
|
|
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
6
|
use Carp (); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
1202
|
|
6
|
|
|
|
|
|
|
our $VERSION = '1.01'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub TIESCALAR { |
10
|
|
|
|
|
|
|
|
11
|
4
|
|
|
4
|
|
8
|
my ( $class , $ref ) = @_ ; |
12
|
4
|
50
|
|
|
|
11
|
ref($ref) or $ref = \$_[1]; |
13
|
4
|
50
|
|
|
|
11
|
if ( tied($$ref) ) { |
14
|
|
|
|
|
|
|
# we are re-tieing something |
15
|
0
|
|
|
|
|
0
|
return tied ($$ref); |
16
|
|
|
|
|
|
|
}else{ |
17
|
|
|
|
|
|
|
# $ref is already a pointer to the object |
18
|
4
|
|
|
|
|
16
|
bless $ref, $class; |
19
|
|
|
|
|
|
|
}; |
20
|
|
|
|
|
|
|
}; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub STORE { |
23
|
3
|
|
|
3
|
|
6
|
${$_[0]} = $_[1]; |
|
3
|
|
|
|
|
12
|
|
24
|
|
|
|
|
|
|
}; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub FETCH { |
28
|
9
|
|
|
9
|
|
28
|
${$_[0]}; |
|
9
|
|
|
|
|
111
|
|
29
|
|
|
|
|
|
|
}; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub TIEARRAY { |
32
|
1
|
|
|
1
|
|
9
|
goto &Tie::Alias::Array::TIEARRAY; |
33
|
|
|
|
|
|
|
}; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub TIEHASH { |
36
|
1
|
|
|
1
|
|
6
|
goto &Tie::Alias::Hash::TIEHASH; |
37
|
|
|
|
|
|
|
}; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub import { |
41
|
1
|
50
|
|
1
|
|
19
|
@_ == 1 and return; |
42
|
0
|
|
|
|
|
0
|
shift; |
43
|
0
|
|
|
|
|
0
|
goto &alias; |
44
|
|
|
|
|
|
|
}; |
45
|
|
|
|
|
|
|
sub alias(@) { |
46
|
1
|
50
|
|
1
|
0
|
23
|
@_ % 2 and Carp::croak "Uneven alias => original pairings in use Tie::Alias"; |
47
|
|
|
|
|
|
|
|
48
|
1
|
|
|
|
|
6
|
while(@_){ |
49
|
4
|
|
|
|
|
8
|
my $r = ref($_[0]); |
50
|
4
|
50
|
|
|
|
10
|
if (!$r){ |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
51
|
4
|
|
|
|
|
19
|
tie $_[0], __PACKAGE__, \$_[1]; |
52
|
|
|
|
|
|
|
}elsif( $r eq 'ARRAY' ){ |
53
|
0
|
|
|
|
|
0
|
tie @{$_[0]}, __PACKAGE__, $_[1]; |
|
0
|
|
|
|
|
0
|
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
}elsif( $r eq 'HASH' ){ |
56
|
0
|
|
|
|
|
0
|
tie %{$_[0]}, __PACKAGE__, $_[1]; |
|
0
|
|
|
|
|
0
|
|
57
|
|
|
|
|
|
|
}else{ |
58
|
|
|
|
|
|
|
# Carp::carp "Object references already have aliasing semantics"; |
59
|
0
|
|
|
|
|
0
|
tie $_[0], __PACKAGE__, \$_[1]; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
}; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
|
65
|
4
|
|
|
|
|
7
|
shift; shift; |
|
4
|
|
|
|
|
12
|
|
66
|
|
|
|
|
|
|
}; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
}; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
package Tie::Alias::Array; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub TIEARRAY { |
76
|
|
|
|
|
|
|
|
77
|
1
|
|
|
1
|
|
3
|
my ( $class , $ref ) = @_ ; |
78
|
1
|
|
|
|
|
2
|
my $rval = eval { |
79
|
1
|
50
|
|
|
|
4
|
if ( tied(@$ref) ) { |
80
|
|
|
|
|
|
|
# we are re-aliasing something |
81
|
0
|
|
|
|
|
0
|
return tied ($$ref); |
82
|
|
|
|
|
|
|
}else{ |
83
|
|
|
|
|
|
|
# $ref is already a pointer to the object |
84
|
1
|
|
|
|
|
4
|
return bless $ref, __PACKAGE__; |
85
|
|
|
|
|
|
|
}; |
86
|
|
|
|
|
|
|
}; |
87
|
1
|
50
|
|
|
|
5
|
$@ and Carp::croak "$ref IS NOT AN ARRAY REFERENCE"; |
88
|
1
|
|
|
|
|
312
|
return $rval; |
89
|
|
|
|
|
|
|
}; |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub FETCH{ |
92
|
0
|
|
|
0
|
|
0
|
$_[0]->[$_[1]]; |
93
|
|
|
|
|
|
|
}; |
94
|
|
|
|
|
|
|
sub STORE{ |
95
|
0
|
|
|
0
|
|
0
|
$_[0]->[$_[1]] = $_[2]; |
96
|
|
|
|
|
|
|
}; |
97
|
|
|
|
|
|
|
sub FETCHSIZE{ |
98
|
0
|
|
|
0
|
|
0
|
scalar @{$_[0]}; |
|
0
|
|
|
|
|
0
|
|
99
|
|
|
|
|
|
|
}; |
100
|
|
|
|
|
|
|
sub STORESIZE{ |
101
|
0
|
|
|
0
|
|
0
|
$#{$_[0]} = $_[1] -1 ; |
|
0
|
|
|
|
|
0
|
|
102
|
|
|
|
|
|
|
}; |
103
|
|
|
|
|
|
|
sub POP{ |
104
|
0
|
|
|
0
|
|
0
|
pop @{$_[0]}; |
|
0
|
|
|
|
|
0
|
|
105
|
|
|
|
|
|
|
}; |
106
|
|
|
|
|
|
|
sub CLEAR{ |
107
|
0
|
|
|
0
|
|
0
|
@{$_[0]} = (); |
|
0
|
|
|
|
|
0
|
|
108
|
|
|
|
|
|
|
}; |
109
|
|
|
|
|
|
|
sub PUSH{ |
110
|
0
|
|
|
0
|
|
0
|
my $r = shift; |
111
|
0
|
|
|
|
|
0
|
push @{$r}, @_; |
|
0
|
|
|
|
|
0
|
|
112
|
|
|
|
|
|
|
}; |
113
|
|
|
|
|
|
|
sub SHIFT{ |
114
|
0
|
|
|
0
|
|
0
|
shift @{$_[0]}; |
|
0
|
|
|
|
|
0
|
|
115
|
|
|
|
|
|
|
}; |
116
|
|
|
|
|
|
|
sub UNSHIFT{ |
117
|
0
|
|
|
0
|
|
0
|
my $r = shift; |
118
|
0
|
|
|
|
|
0
|
unshift @{$r}, @_; |
|
0
|
|
|
|
|
0
|
|
119
|
|
|
|
|
|
|
}; |
120
|
|
|
|
|
|
|
sub SPLICE{ |
121
|
0
|
|
|
0
|
|
0
|
my $r = shift; |
122
|
0
|
|
0
|
|
|
0
|
my $o = shift || 0; |
123
|
0
|
|
0
|
|
|
0
|
my $l = shift || scalar(@{$r}) - $o; |
124
|
0
|
|
|
|
|
0
|
splice @{$r}, $o, $l, @_; |
|
0
|
|
|
|
|
0
|
|
125
|
|
|
|
|
|
|
}; |
126
|
|
|
|
|
|
|
sub DELETE{ |
127
|
0
|
|
|
0
|
|
0
|
delete $_[0]->[$_[1]]; |
128
|
|
|
|
|
|
|
}; |
129
|
|
|
|
|
|
|
sub EXISTS{ |
130
|
0
|
|
|
0
|
|
0
|
exists $_[0]->[$_[1]]; |
131
|
|
|
|
|
|
|
}; |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
package Tie::Alias::Hash; |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
sub TIEHASH { |
137
|
1
|
|
|
1
|
|
4
|
my ( $class , $ref ) = @_ ; |
138
|
1
|
|
|
|
|
3
|
my $rval = eval { |
139
|
1
|
50
|
|
|
|
5
|
if ( tied(%$ref) ) { |
140
|
|
|
|
|
|
|
# we are re-aliasing something |
141
|
0
|
|
|
|
|
0
|
return tied (%$ref); |
142
|
|
|
|
|
|
|
}else{ |
143
|
|
|
|
|
|
|
# $ref is already a pointer to the object |
144
|
1
|
|
|
|
|
5
|
return bless $ref, __PACKAGE__; |
145
|
|
|
|
|
|
|
}; |
146
|
|
|
|
|
|
|
}; |
147
|
1
|
50
|
|
|
|
5
|
$@ and Carp::croak "$ref IS NOT A HASH REFERENCE"; |
148
|
1
|
|
|
|
|
4
|
return $rval; |
149
|
|
|
|
|
|
|
}; |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
sub FETCH{ |
153
|
0
|
|
|
0
|
|
|
$_[0]->{$_[1]}; |
154
|
|
|
|
|
|
|
}; |
155
|
|
|
|
|
|
|
sub STORE{ |
156
|
0
|
|
|
0
|
|
|
$_[0]->{$_[1]} = $_[2]; |
157
|
|
|
|
|
|
|
}; |
158
|
|
|
|
|
|
|
sub EXISTS{ |
159
|
0
|
|
|
0
|
|
|
exists $_[0]->{$_[1]}; |
160
|
|
|
|
|
|
|
}; |
161
|
|
|
|
|
|
|
sub DELETE{ |
162
|
0
|
|
|
0
|
|
|
delete $_[0]->{$_[1]}; |
163
|
|
|
|
|
|
|
}; |
164
|
|
|
|
|
|
|
sub CLEAR{ |
165
|
0
|
|
|
0
|
|
|
%{$_[0]} = (); |
|
0
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
}; |
167
|
|
|
|
|
|
|
sub FIRSTKEY{ |
168
|
0
|
|
|
0
|
|
|
keys %{$_[0]}; |
|
0
|
|
|
|
|
|
|
169
|
0
|
|
|
|
|
|
each %{$_[0]}; |
|
0
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
}; |
171
|
|
|
|
|
|
|
sub NEXTKEY{ |
172
|
0
|
|
|
0
|
|
|
each %{$_[0]}; |
|
0
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
}; |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
1; |
176
|
|
|
|
|
|
|
__END__ |