| 1 | package Pipe::Tube::Cat; | ||||||||||
| 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 | 19 | ▶ | sub init { | ||||||||
|
Subroutine
init: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 11 | 19 | my ($self, @files) = @_; | |||||||||
| 12 | 19 | @{ $self->{files} } = @files; | |||||||||
| 13 | |||||||||||
| 14 | 19 | return $self; | |||||||||
| 15 | } | ||||||||||
| 16 | |||||||||||
| 17 | # implement <> here | ||||||||||
| 18 | 128 | ▶ | sub run { | ||||||||
|
Subroutine
run: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||
| 19 | 128 | my ($self, @files) = @_; | |||||||||
| 20 | |||||||||||
| 21 | 128 | push @{ $self->{files} }, @files; | |||||||||
| 22 | |||||||||||
| 23 | 128 | my $fh = $self->{fh}; | |||||||||
| 24 | 128 | while (1) { | |||||||||
| 25 | 157 | ▶ | if (not defined $fh) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 26 | 47 | $fh = $self->_next_file; | |||||||||
| 27 | } | ||||||||||
| 28 | 157 | ▶ | return if not $fh; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 29 | 139 | my $row = <$fh>; | |||||||||
| 30 | 139 | ▶ | if (defined $row) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 31 | 110 | $self->logger("Row read: $row"); | |||||||||
| 32 | 110 | return $row; | |||||||||
| 33 | } else { | ||||||||||
| 34 | 29 | $fh = undef; | |||||||||
| 35 | } | ||||||||||
| 36 | } | ||||||||||
| 37 | } | ||||||||||
| 38 | |||||||||||
| 39 | 47 | ▶ | sub _next_file { | ||||||||
|
Subroutine
_next_file: called CC=3 SCAR=11.0
| |||||||||||
| 40 | 47 | my ($self) = @_; | |||||||||
| 41 | 47 | ▶ | while (my $file = shift @{ $self->{files} }) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 42 | 30 | $self->logger("Opening file '$file'"); | |||||||||
| 43 | 30 | ▶ | if (open my $fh, "<", $file) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 44 | 29 | return $self->{fh} = $fh; | |||||||||
| 45 | } else { | ||||||||||
| 46 | 1 | warn "Could not open '$file'. $!\n"; | |||||||||
| 47 | } | ||||||||||
| 48 | } | ||||||||||
| 49 | } | ||||||||||
| 50 | |||||||||||
| 51 | 1 | 1; | |||||||||
| 52 | |||||||||||