| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
=pod |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
ETL::Pipeline::Output::Perl - Execute arbitrary Perl code against every record |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use ETL::Pipeline; |
|
10
|
|
|
|
|
|
|
ETL::Pipeline->new( { |
|
11
|
|
|
|
|
|
|
input => ['UnitTest'], |
|
12
|
|
|
|
|
|
|
mapping => {First => 'Header1', Second => 'Header2'}, |
|
13
|
|
|
|
|
|
|
output => ['Perl', code => sub { say $_->{First} }] |
|
14
|
|
|
|
|
|
|
} )->process; |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
B<ETL::Pipeline::Output::Perl> runs arbitrary Perl code for every record. It |
|
19
|
|
|
|
|
|
|
comes in useful when debugging data issues or prototyping a new technique. |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
Your code receives two parameters - the L<ETL::Pipeline> object and the current |
|
22
|
|
|
|
|
|
|
record. These are the same arguments passed to L</write>. The current record is |
|
23
|
|
|
|
|
|
|
a Perl hash reference. |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=cut |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
package ETL::Pipeline::Output::Perl; |
|
28
|
|
|
|
|
|
|
|
|
29
|
1
|
|
|
1
|
|
25
|
use 5.014000; |
|
|
1
|
|
|
|
|
3
|
|
|
30
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
28
|
|
|
31
|
|
|
|
|
|
|
|
|
32
|
1
|
|
|
1
|
|
4
|
use Moose; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
7
|
|
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
our $VERSION = '3.00'; |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head1 METHODS & ATTRIBUTES |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head2 Arguments for L<ETL::Pipeline/output> |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head3 code |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
Required. Assign a code reference to this attribute. The code receives two |
|
45
|
|
|
|
|
|
|
parameters. The first one is the L<ETL::Pipeline> object. The second is a hash |
|
46
|
|
|
|
|
|
|
reference with the current record. |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
The code reference can do anything you want. If you need setup or shut down, |
|
49
|
|
|
|
|
|
|
then create a L<custom output destination|ETL::Pipeline::Output> instead. |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=cut |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
has 'code' => ( |
|
54
|
|
|
|
|
|
|
is => 'ro', |
|
55
|
|
|
|
|
|
|
isa => 'CodeRef', |
|
56
|
|
|
|
|
|
|
required => 1, |
|
57
|
|
|
|
|
|
|
); |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head2 Methods |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head3 close |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
This method doesn't do anything. There's nothing to close or shut down. |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=cut |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
1
|
1
|
|
sub close {} |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head3 open |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
This method doesn't do anything. There's nothing to open or setup. |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=cut |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
1
|
1
|
|
sub open {} |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head3 write |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Executes the subroutine in L</code>. The arguments are passed directly into the |
|
82
|
|
|
|
|
|
|
subroutine. |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=cut |
|
85
|
|
|
|
|
|
|
|
|
86
|
2
|
|
|
2
|
1
|
48
|
sub write { return shift->code->( @_ ); } |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
L<ETL::Pipeline>, L<ETL::Pipeline::Output> |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=cut |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
with 'ETL::Pipeline::Output'; |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 AUTHOR |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
Robert Wohlfarth <robert.j.wohlfarth@vumc.org> |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head1 LICENSE |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Copyright 2021 (c) Vanderbilt University |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it under |
|
107
|
|
|
|
|
|
|
the same terms as Perl itself. |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=cut |
|
110
|
|
|
|
|
|
|
|
|
111
|
1
|
|
|
1
|
|
6305
|
no Moose; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
6
|
|
|
112
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |