Provided by: libcatmandu-perl_0.9505-1_all
NAME
Catmandu::Exporter - Namespace for packages that can export
SYNOPSIS
package Catmandu::Exporter::Foo; use Catmandu::Sane; use Moo; with 'Catmandu::Exporter' sub add { my ($self, $data) = @_; my $fh = $self->fh; $fh->print( ... ); } package main; use Catmandu; my $exporter = Catmandu->exporter('Foo', file => "/tmp/output.txt"); # Or on the command line $ catmandu convert JSON to Foo < /tmp/something.txt >/tmp/output.txt
DESCRIPTION
A Catmandu::Exporter is a Perl package that can export data. By default, data items are written to STDOUT. Optionally provide a "file" or "fh" parameter to write to a file, string, or handle. New exporter modules are expected to use the "print" method of "fh". Every Catmandu::Exporter is a Catmandu::Fixable thus provides a "fix" parameter and method to apply fixes to exported items. Every Catmandu::Exporter is a Catmandu::Addable thus inherits the methods "add" and "add_many".
CONFIGURATION
file Write output to a local file given by its path or file handle. Alternatively a scalar reference can be passed to write to a string and a code reference can be used to write to a callback function. fh Write the output to an IO::Handle. If not specified, Catmandu::Util::io is used to create the output handle from the "file" argument or by using STDOUT. encoding Binmode of the output stream "fh". Set to "":utf8"" by default. fix An ARRAY of one or more fixes or file scripts to be applied to exported items.
METHODS
add Adds one object to be exported. add_many Adds many objects to be exported. This can be either an ARRAY-ref or an Catmandu::Iterator. Returns a true value when the export was successful or undef on error. count Returns the number of items exported by this Catmandu::Exporter. log Returns the current logger.
SEE ALSO
See function export_to_string in module Catmandu. The exporters Catmandu::Exporter::JSON, Catmandu::Exporter::YAML, Catmandu::Exporter::CSV, and Catmandu::Exporter::RIS are included in Catmandu core. See Catmandu::Importer for the opposite action.