| 1 | package Data::RoundRobin; | ||||||||||||
| 2 | 7 | ▶ | use 5.006001; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 3 | 7 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 4 | 7 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | 7 | our $VERSION = '0.03'; | |||||||||||
| 6 | |||||||||||||
| 7 | use overload | ||||||||||||
| 8 | 7 | ▶ | 'eq' => \&next, | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 9 | 'ne' => \&next, | ||||||||||||
| 10 | "cmp" => \&next, | ||||||||||||
| 11 | "<=>" => \&next, | ||||||||||||
| 12 | '+' => \&numerify, | ||||||||||||
| 13 | '==' => \&numerify, | ||||||||||||
| 14 | 7 | '""' => \&next; | |||||||||||
| 15 | |||||||||||||
| 16 | 7 | ▶ | sub new { | ||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 17 | 7 | my ($class, @arr) = @_; | |||||||||||
| 18 | 7 | my $self = { | |||||||||||
| 19 | array => \@arr, | ||||||||||||
| 20 | current => 0, | ||||||||||||
| 21 | total => scalar(@arr), | ||||||||||||
| 22 | }; | ||||||||||||
| 23 | 7 | return bless $self; | |||||||||||
| 24 | } | ||||||||||||
| 25 | |||||||||||||
| 26 | 63 | ▶ | sub next { | ||||||||||
|
Subroutine
next: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 27 | 63 | my $self = shift; | |||||||||||
| 28 | 63 | my $r = $self->{array}->[$self->{current}]; | |||||||||||
| 29 | 63 | $self->{current}++; | |||||||||||
| 30 | 63 | $self->{current} %= $self->{total}; | |||||||||||
| 31 | 63 | return $r; | |||||||||||
| 32 | } | ||||||||||||
| 33 | |||||||||||||
| 34 | 9 | ▶ | sub numerify { | ||||||||||
|
Subroutine
numerify: called CC=3 SCAR=11.2
Pod
documented
| |||||||||||||
| 35 | 9 | my $self = shift; | |||||||||||
| 36 | 9 | ▶ | my $other = shift || 0; | ||||||||||
|
Condition50%1/2
shift() || 0
MC/DC0%0/1
shift() || 0
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||
| 37 | 9 | my $value = $self->next; | |||||||||||
| 38 | 9 | $value =~ s/^(\d*).*$/$1/; | |||||||||||
| 39 | 9 | ▶ | $value ||= 0; | ||||||||||
|
Condition50%1/2
$value ||= 0
MC/DC0%0/1
$value ||= 0
$value
Truth table50%1/2
A
A= $value
| |||||||||||||
| 40 | 9 | return $value + $other; | |||||||||||
| 41 | } | ||||||||||||
| 42 | |||||||||||||
| 43 | 7 | 1; | |||||||||||
| 44 | |||||||||||||
| 45 | __END__ | ||||||||||||