line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Pipe::Tube::Csv; |
2
|
1
|
|
|
1
|
|
3460
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
32
|
|
3
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
41
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.04'; |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
17
|
use base 'Pipe::Tube'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
67
|
|
8
|
1
|
|
|
1
|
|
1048
|
use Text::CSV; |
|
1
|
|
|
|
|
13616
|
|
|
1
|
|
|
|
|
7
|
|
9
|
1
|
|
|
1
|
|
1268
|
use Data::Dumper; |
|
1
|
|
|
|
|
7255
|
|
|
1
|
|
|
|
|
251
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub init { |
13
|
1
|
|
|
1
|
0
|
272
|
my ($self, $attr) = @_; |
14
|
1
|
50
|
33
|
|
|
7
|
die "First paramater of csv should be HASH reference or nothing" if $attr and ref $attr ne 'HASH'; |
15
|
1
|
|
50
|
|
|
9
|
$attr ||= {}; |
16
|
|
|
|
|
|
|
|
17
|
1
|
|
|
|
|
4
|
$self->logger("Receiving Csv definition: " . Dumper $attr); |
18
|
|
|
|
|
|
|
|
19
|
1
|
|
|
|
|
99
|
$self->{csv} = Text::CSV->new($attr); |
20
|
|
|
|
|
|
|
|
21
|
1
|
|
|
|
|
97
|
return $self; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub run { |
25
|
4
|
|
|
4
|
0
|
191
|
my ($self, @input) = @_; |
26
|
|
|
|
|
|
|
|
27
|
4
|
|
|
|
|
5
|
my @resp; |
28
|
4
|
|
|
|
|
9
|
foreach my $line (@input) { |
29
|
2
|
|
|
|
|
8
|
$self->{csv}->parse($line); |
30
|
2
|
|
|
|
|
577
|
push @resp, [ $self->{csv}->fields ]; |
31
|
|
|
|
|
|
|
} |
32
|
4
|
|
|
|
|
28
|
return @resp; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
1; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
__END__ |