| 1 | package Pipe::Tube::Tuple; | ||||||||||
| 2 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | ▶ | use 5.006; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 1 | ▶ | use base 'Pipe::Tube'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 1 | our $VERSION = '0.06'; | |||||||||
| 9 | |||||||||||
| 10 | 2 | ▶ | sub init { | ||||||||
|
Subroutine
init: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||
| 11 | 2 | my ($self, @arrays) = @_; | |||||||||
| 12 | 2 | $self->{sources} = \@arrays; | |||||||||
| 13 | 2 | $self->{current_index} = 0; | |||||||||
| 14 | |||||||||||
| 15 | 2 | my $l = 0; | |||||||||
| 16 | 2 | ▶ | $l = ($l > @$_ ? $l : @$_) for @arrays; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 17 | 2 | $self->{longest_array} = $l; | |||||||||
| 18 | |||||||||||
| 19 | 2 | $self->logger("The tuple received " . @arrays . " sources"); | |||||||||
| 20 | 2 | return $self; | |||||||||
| 21 | } | ||||||||||
| 22 | |||||||||||
| 23 | 10 | ▶ | sub run { | ||||||||
|
Subroutine
run: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||
| 24 | 10 | my ($self) = @_; | |||||||||
| 25 | |||||||||||
| 26 | 10 | ▶ | return if $self->{current_index} >= $self->{longest_array}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 27 | |||||||||||
| 28 | 8 | my @tuple; | |||||||||
| 29 | 8 | foreach my $source (@{ $self->{sources} }) { | |||||||||
| 30 | 12 | push @tuple, $source->[ $self->{current_index} ]; | |||||||||
| 31 | } | ||||||||||
| 32 | 8 | $self->{current_index}++; | |||||||||
| 33 | 8 | return \@tuple; | |||||||||
| 34 | } | ||||||||||
| 35 | |||||||||||
| 36 | |||||||||||
| 37 | 1 | 1; | |||||||||
| 38 | |||||||||||