line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
27505
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
24
|
|
2
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
46
|
|
3
|
|
|
|
|
|
|
package Tie::Scalar::Ratio; |
4
|
|
|
|
|
|
|
$Tie::Scalar::Ratio::VERSION = '0.01'; |
5
|
1
|
|
|
1
|
|
780
|
use parent 'Tie::Scalar'; |
|
1
|
|
|
|
|
334
|
|
|
1
|
|
|
|
|
5
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
#ABSTRACT: a scalar which multiplies in value every time it is accessed. |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub TIESCALAR { |
10
|
5
|
|
|
5
|
|
96
|
my ($class, $ratio, $value) = @_; |
11
|
|
|
|
|
|
|
|
12
|
5
|
100
|
100
|
|
|
72
|
die 'Must provide ratio argument, a number to multiply the scalar value by' |
13
|
|
|
|
|
|
|
unless $ratio && $ratio =~ /^[\d.]+$/; |
14
|
|
|
|
|
|
|
|
15
|
2
|
|
|
|
|
16
|
bless { |
16
|
|
|
|
|
|
|
ratio => $ratio, |
17
|
|
|
|
|
|
|
value => $value, |
18
|
|
|
|
|
|
|
}, $class; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub STORE { |
22
|
2
|
|
|
2
|
|
5
|
my ($self, $value) = @_; |
23
|
2
|
|
|
|
|
10
|
$self->{value} = $value; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub FETCH { |
27
|
11
|
|
|
11
|
|
132
|
my ($self) = @_; |
28
|
11
|
|
|
|
|
18
|
my $old_value = $self->{value}; |
29
|
11
|
50
|
|
|
|
31
|
$self->{value} *= $self->{ratio} if $self->{value}; |
30
|
11
|
|
|
|
|
37
|
return $old_value; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
1; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
__END__ |