NAME

PICA::PlainParser - Parse normalized PICA+

SYNOPSIS

my $parser = PICA::PlainParser->new(
    Field => \&field_handler,
    Record => \&record_handler
);

$parser->parsefile($filename);

sub field_handler {
    my $field = shift;
    print $field->to_string();
    # no need to save the field so do not return it
}

sub record_handler {
    print "\n";
}

DESCRIPTION

This module contains a parser for normalized PICA+

PUBLIC METHODS

new (params)

Create a new parser. See PICA::Parser for a detailed description of the possible parameters Field, Record, and Collection. Additionally you may specify the parameter EmptyRecords to define that empty records will not be skipped but passed to the record handler and Strict to abort when an error occured. Default behaviour is not strict: errors are reported to STDERR.

parsefile ( $file-or-handle [, options] )

Parses a file, specified by a filename or file handle. Additional possible parameters are handlers (Field, Record, Collection) and options (Strict, EmptyRecords). If you supply a filename with extension .gz then it is extracted while reading with zcat, if the extension is .zip then unzip is used to extract.

This method temporarily changes the end-of-line character if parsing in dumpformat is requested.

parsedata ( $data )

Parses PICA+ data from a string, array or function. If you supply a function then this function is must return scalars or arrays and it is called unless it returns undef.

records ( )

Get an array of the read records (if they have been stored)

counter ( )

Get the number of read records so far.

empty ( )

Get the number of empty records that have been read so far. By default empty records are not passed to the record handler but counted.

PRIVATE METHODS

_parsedata

Parses a string or an array reference.

_parseline

Parses a line (without trailing newline character). May throw an exception with croak.

handle_record

Calls the record handler.

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.