NAME

PICA::Writer - Write and count PICA+ records and fields

SYNOPSIS

my $writer = PICA::Writer->new( \*STDOUT );

$writer->write( $record );
$writer->write( $comment, $record );

print $writer->counter() . " records, " . $writer->fields() . " fields\n";

$writer->writefield( $field );
$writer->reset();

$writer = PICA::Writer->new( \*STDOUT, format => 'xml' );
$writer = PICA::Writer->new( \*STDOUT, format => 'plain' );

DESCRIPTION

This module contains a simple class to write and count PICA+ records and fields (printing of single fields may not be possible in all implementations).

METHODS

new ( [ <file-or-handle> ] [, %parameters ] )

Create a new parser. You can path a reference to a handle or a file name and additional parameters. If file or handle is specified then the writer will not write but count records. The only parameter so far is format (with value xml, normalized, or plain).

reset ( [ $filename | $handle ] )

Reset the writer by setting the counters to zero. You may also specify a new handle or file name. This methods returns the writer itself.

reset_handler

Reset the file handler or file name without resetting the counters.

write

Write a record(s) of type PICA::Record. You may specify strings before a record that will be used as a comment:

$writer->write( $record );
$writer->write( @records );
$writer->write( "Record number: $counter", $record );

writefield

Write one ore more PICA::Field. Please be aware that the output will not be wellformed PICA+ if you have not written a start record marker before!

counter

Returns the number of written records.

fields

Returns the number of written fields.

name

Returns the name of the writer (usually the filename) if defined.

AUTHOR

Jakob Voss <jakob.voss@gbv.de>

LICENSE

Copyright (C) 2007 by Verbundzentrale Goettingen (VZG) and Jakob Voss

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.