line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Tie::Scalar::Random; |
2
|
4
|
|
|
4
|
|
135733
|
use strict; |
|
4
|
|
|
|
|
437
|
|
|
4
|
|
|
|
|
187
|
|
3
|
4
|
|
|
4
|
|
26
|
use warnings; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
1449
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub TIESCALAR { |
8
|
4
|
|
|
4
|
|
584
|
my $class = shift; |
9
|
4
|
|
|
|
|
10
|
my $remember_all = shift; |
10
|
4
|
100
|
|
|
|
20
|
if ($remember_all) { |
11
|
2
|
|
|
|
|
17
|
return bless {remember_all => 1, values => []}, $class; |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
else { |
14
|
2
|
|
|
|
|
14
|
return bless {assigned => 0, value => undef}, $class; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub FETCH { |
19
|
701
|
|
|
701
|
|
2966
|
my $self = shift; |
20
|
|
|
|
|
|
|
|
21
|
701
|
100
|
|
|
|
1518
|
if ($self->{remember_all}) { |
22
|
401
|
|
|
|
|
549
|
return $self->{values}->[ rand @{$self->{values}} ]; |
|
401
|
|
|
|
|
1658
|
|
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
300
|
|
|
|
|
866
|
return $self->{value}; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub STORE { |
29
|
201
|
|
|
201
|
|
59292
|
my $self = shift; |
30
|
201
|
|
|
|
|
304
|
my $value = shift; |
31
|
|
|
|
|
|
|
|
32
|
201
|
100
|
|
|
|
854
|
if ($self->{remember_all}) { |
|
|
100
|
|
|
|
|
|
33
|
101
|
|
|
|
|
313
|
push @{ $self->{values} }, $value; |
|
101
|
|
|
|
|
337
|
|
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
elsif (rand(++$self->{assigned}) < 1) { |
36
|
6
|
|
|
|
|
13
|
$self->{value} = $value; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
201
|
|
|
|
|
403
|
return $self->FETCH; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub DESTROY { |
43
|
4
|
|
|
4
|
|
2087
|
my $self = shift; |
44
|
4
|
|
|
|
|
689
|
%$self = (); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
1; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
__END__ |