Man pages sections > man3 > Catmandu::Exporter::Text

Catmandu::Exporter::Text - a Text exporter

Catmandu::Exporter::Text(3pm) User Contributed Perl Documentation Catmandu::Exporter::Text(3pm)

NAME

Catmandu::Exporter::Text - a Text exporter

SYNOPSIS

    # From the command line
    # Write all field values as a line of Text
    $ catmandu convert JSON to Text --field_sep "," < data.json
    # In a Perl script
    use Catmandu;
    # Print to STDOUT
    my $exporter = Catmandu->exporter('Text', fix => 'myfix.txt');
    # Print to file or IO::Handle
    my $exporter = Catmandu->exporter('Text', file => '/tmp/out.yml');
    my $exporter = Catmandu->exporter('Text', file => $fh);
    $exporter->add_many($arrayref);
    $exporter->add_many($iterator);
    $exporter->add_many(sub { });
    $exporter->add($hashref);
    printf "exported %d objects\n" , $exporter->count;

DESCRIPTION

This "Catmandu::Exporter" exports items as raw text. All field values found in the data will be contactenated using "field_sep" as delimiter.

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.
fix
An ARRAY of one or more fixes or file scripts to be applied to exported items.
encoding
Binmode of the output stream "fh". Set to "":utf8"" by default.
line_sep STR
Use the STR at each end of line. Set to ""\n"" by default.
field_sep STR
Use the STR at each end of a field.

SEE ALSO

Catmandu::Exporter , Catmandu::Importer::Text
2017-10-01 perl v5.26.0