NAME

PICA::Writer::Base - Base class of PICA+ writers

SYNOPSIS

use PICA::Writer::Plain;
my $writer = PICA::Writer::Plain->new( $fh );

foreach my $record (@pica_records) {
    $writer->write($record);
}

use PICA::Writer::Plus;
$writer = PICA::Writer::Plus->new( $fh );
...

use PICA::Writer::XML;
$writer = PICA::Writer::XML->new( $fh );
...

DESCRIPTION

This abstract base class of PICA+ writers should not be instantiated directly. Use one of the following subclasses instead:

PICA::Writer::Plain
PICA::Writer::Plus
PICA::Writer::XML
PICA::Writer::PPXML
PICA::Writer::JSON

METHODS

new( [ $fh | fh => $fh ] [ %options ] )

Create a new PICA writer, writing to STDOUT by default. The optional fh argument can be a filename, a handle or any other blessed object with a print method, e.g. IO::Handle.

PICA::Data also provides a functional constructor pica_writer.

write ( @records )

Writes one or more records, given as hash with key 'record' or as array reference with a list of fields, as described in PICA::Data.

write_record ( $record )

Writes one record.

end

Finishes writing by closing the file handle (unless writing to STDOUT).

OPTIONS

color

Syntax highlighting can be enabled for PICA::Writer::Plain and PICA::Writer::Plus using color names from Term::ANSIColor, e.g.

pica_writer('plain', color => {
  tag => 'blue',
  occurrence => 'magenta',
  code => 'green',
  value => 'white',
  syntax => 'yellow',
})

SEE ALSO

See Catmandu::Exporter::PICA for usage of this module within the Catmandu framework (recommended).

Alternative (outdated) PICA+ writers had been implemented as PICA::Writer and PICA::XMLWriter included in the release of PICA::Record.