NAME
ETL::Pipeline::Output::Perl - Execute arbitrary Perl code against every record
SYNOPSIS
use ETL::Pipeline;
ETL::Pipeline->new( {
input => ['UnitTest'],
mapping => {First => 'Header1', Second => 'Header2'},
output => ['Perl', code => sub { say $_->{First} }]
} )->process;
DESCRIPTION
ETL::Pipeline::Output::Perl runs arbitrary Perl code for every record. It comes in useful when debugging data issues or prototyping a new technique.
ETL::Pipeline::Output::Perl stores the record in a hash (see "current"). The class passes that hash reference into your subroutine.
METHODS & ATTRIBUTES
Arguments for "output" in ETL::Pipeline
code
Assign this attribute your code reference. Your code receives two parameters. The first one is the ETL::Pipeline object. The second is the hash reference with the data record.
The code reference can do anything. It should return a boolean. True means success and false means failure. You determine what success or failure really means.
WARNING: Do not save the hash reference. Make a copy of the hash instead. ETL::Pipeline::Output::Perl re-uses the same hash reference. The second record will overwrite the first, etc.
Called from "process" in ETL::Pipeline
write_record
Passes the subroutine in "code" to "execute_code_ref" in ETL::Pipeline. "current" is passed to the subroutine as a parameter.
configure
configure doesn't actually do anything. But it is required by "process" in ETL::Pipeline.
finish
finish doesn't actually do anything. But it is required by "process" in ETL::Pipeline.
Other methods and attributes
default_fields
Initialize "current" for the next record.
SEE ALSO
ETL::Pipeline, ETL::Pipeline::Output, ETL::Pipeline::Output::Storage::Hash
AUTHOR
Robert Wohlfarth <robert.j.wohlfarth@vanderbilt.edu>
LICENSE
Copyright 2016 (c) Vanderbilt University
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.