line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Tie::NumRange; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
$VERSION = '0.021'; |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
sub TIESCALAR { |
7
|
3
|
|
|
3
|
|
82
|
my $class = shift; |
8
|
3
|
|
|
|
|
10
|
my $self = bless [ @_ ], $class; |
9
|
3
|
|
|
|
|
9
|
$self->STORE($_[0]); # just in case |
10
|
3
|
|
|
|
|
7
|
return $self; |
11
|
|
|
|
|
|
|
} |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub STORE { |
15
|
9
|
|
|
9
|
|
21
|
my ($self,$val) = @_; |
16
|
|
|
|
|
|
|
|
17
|
9
|
100
|
66
|
|
|
55
|
return $self->[0] = $self->[1] if |
18
|
|
|
|
|
|
|
defined($self->[1]) and |
19
|
|
|
|
|
|
|
$self->[1] > $val; |
20
|
|
|
|
|
|
|
|
21
|
8
|
100
|
66
|
|
|
35
|
return $self->[0] = $self->[2] if |
22
|
|
|
|
|
|
|
defined($self->[2]) and |
23
|
|
|
|
|
|
|
$self->[2] < $val; |
24
|
|
|
|
|
|
|
|
25
|
7
|
|
|
|
|
16
|
return $self->[0] = $val; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
29
|
9
|
|
|
9
|
|
105
|
sub FETCH { $_[0][0] } |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
package Tie::NumRange::Wrap; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub TIESCALAR { |
36
|
1
|
|
|
1
|
|
66
|
my $class = shift; |
37
|
1
|
50
|
|
|
|
7
|
die "tie()ing to $class requires a lower and upper bound" if |
38
|
|
|
|
|
|
|
grep !defined, @_[1,2]; |
39
|
1
|
|
|
|
|
3
|
my $self = bless [ @_ ], $class; |
40
|
1
|
|
|
|
|
5
|
$self->STORE($_[0]); # just in case |
41
|
1
|
|
|
|
|
3
|
return $self; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub STORE { |
46
|
11
|
|
|
11
|
|
11
|
my ($self,$val) = @_; |
47
|
|
|
|
|
|
|
|
48
|
11
|
|
|
|
|
26
|
$val += $self->[2] - $self->[1] while $val < $self->[1]; |
49
|
11
|
|
|
|
|
19
|
$val -= $self->[2] - $self->[1] while $val > $self->[2]; |
50
|
|
|
|
|
|
|
|
51
|
11
|
|
|
|
|
23
|
return $self->[0] = $val; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
55
|
31
|
|
|
31
|
|
71
|
sub FETCH { $_[0][0] } |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
1; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
__END__ |