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
- PICA::Writer::Generic
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. Records are syntactically validated with PICA::Schema's clean_pica
.
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',
})
annotate
Writer PICA::Writer::Plain and PICA::Writer::Plus includes optional field annotations. Set this option to true to enforce field annotations (set to an empty space if missing) or to false to ignore them.
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.