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
. Errors are reported to STDERR.
parsefile ( $filename | $handle )
Parses a file, specified by a filename or file handle or IO::Handle. Additional possible parameters are handlers (Field
, Record
, Collection
) and options (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. Please note that the number of records as returned by the records
method may be lower because you may have filtered out some records.
finished ( )
Return whether the parser will not parse any more records. This is the case if the number of read records is larger then the limit.
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.