line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::RoundRobin; |
2
|
6
|
|
|
6
|
|
7737
|
use 5.006001; |
|
6
|
|
|
|
|
23
|
|
|
6
|
|
|
|
|
266
|
|
3
|
6
|
|
|
6
|
|
35
|
use strict; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
222
|
|
4
|
6
|
|
|
6
|
|
41
|
use warnings; |
|
6
|
|
|
|
|
14
|
|
|
6
|
|
|
|
|
705
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use overload |
8
|
6
|
|
|
|
|
96
|
'eq' => \&next, |
9
|
|
|
|
|
|
|
'ne' => \&next, |
10
|
|
|
|
|
|
|
"cmp" => \&next, |
11
|
|
|
|
|
|
|
"<=>" => \&next, |
12
|
|
|
|
|
|
|
'+' => \&numerify, |
13
|
|
|
|
|
|
|
'==' => \&numerify, |
14
|
6
|
|
|
6
|
|
34
|
'""' => \&next; |
|
6
|
|
|
|
|
13
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub new { |
17
|
7
|
|
|
7
|
1
|
15823
|
my ($class, @arr) = @_; |
18
|
7
|
|
|
|
|
35
|
my $self = { |
19
|
|
|
|
|
|
|
array => \@arr, |
20
|
|
|
|
|
|
|
current => 0, |
21
|
|
|
|
|
|
|
total => scalar(@arr), |
22
|
|
|
|
|
|
|
}; |
23
|
7
|
|
|
|
|
25
|
return bless $self; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub next { |
27
|
63
|
|
|
63
|
1
|
28464
|
my $self = shift; |
28
|
63
|
|
|
|
|
177
|
my $r = $self->{array}->[$self->{current}]; |
29
|
63
|
|
|
|
|
82
|
$self->{current}++; |
30
|
63
|
|
|
|
|
420
|
$self->{current} %= $self->{total}; |
31
|
63
|
|
|
|
|
296
|
return $r; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub numerify { |
35
|
9
|
|
|
9
|
1
|
3599
|
my $self = shift; |
36
|
9
|
|
50
|
|
|
42
|
my $other = shift || 0; |
37
|
9
|
|
|
|
|
21
|
my $value = $self->next; |
38
|
9
|
|
|
|
|
42
|
$value =~ s/^(\d*).*$/$1/; |
39
|
9
|
|
50
|
|
|
38
|
$value ||= 0; |
40
|
9
|
|
|
|
|
32
|
return $value + $other; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
1; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
__END__ |