The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Catmandu::Exporter - Namespace for packages that can export a hashref or an iterable object

SYNOPSIS

    use Catmandu::Exporter::YAML;

    my $exporter = Catmandu::Exporter::YAML->new(fix => 'myfix.txt');

    $exporter->add_many($arrayref);
    $exporter->add_many($iterator);
    $exporter->add_many(sub { });

    $exporter->add($hashref);

    printf "exported %d objects\n" , $exporter->count;

METHODS

new(file => PATH, fh => HANDLE, fix => STRING|ARRAY)

Create a new Catmandu::Exporter. When no options are given exported data is written to the stdout. Optionally provide a 'file' pathname or a 'fh' file handle to redirect the ouput.

Every Catmandu::Exporter is a Catmandu::Fixable and thus provides a 'fix' parameter that can be set in the constructor. For every 'add' or for every item in 'add_many' the given fixes will be applied first.

add($hashref)

Adds one object to be exported. Provide a HASH-ref or an Catmandu::Iterator to loop. Returns a true value when the export was successful or undef on error.

add_many($arrayref)

add_many($iterator)

add_many(sub {})

Provide one or more objects to be exported. The exporter will use array references, iterators and generator routines to loop over all items. Returns the total number of items exported.

count

Returns the number of items exported by this Catmandu::Exporter.

SEE ALSO

Catmandu::Exporter::Fix