PICA::PlainParser - Parse normalized PICA+
version 0.584
my $parser = PICA::PlainParser->new( Field => \&field_handler, Record => \&record_handler ); $parser->parsefile($filename); sub field_handler { my $field = shift; print $field->string; # no need to save the field so do not return it } sub record_handler { print "\n"; }
This module contains a parser for normalized PICA+
Create a new parser. See PICA::Parser for a detailed description of the possible parameters Field, Record, and Collection. Errors are reported to STDERR.
Field
Record
Collection
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.
EmptyRecords
.gz
zcat
.zip
unzip
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. You can also supply a PICA::Record object to be parsed again.
Get an array of the read records (if they have been stored)
Get the number of records that have been (tried to) read. This also includes broken records and other records that have been skipped, for instance by filtering out with the record handler.
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.
Parses a string or an array reference.
Parses a line (without trailing newline character). May throw an exception with croak.
If a line could not be parsed into a PICA::Field, this method is called. If it returns undef, the line is ignored, if it returns a PICA::Field object, this field is used instead and if it returns a true value, the whole record will be marked as broken. This method can be used as error handler. By default it always returns undef and prints an error message to STDERR.
Error handler for broken records. By default prints the errormessage to STDERR if it is defined and the record is not empty.
Calls the record handler.
Jakob Voß <voss@gbv.de>
This software is copyright (c) 2012 by Verbundzentrale Goettingen (VZG) and Jakob Voss.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install PICA::Record, copy and paste the appropriate command in to your terminal.
cpanm
cpanm PICA::Record
CPAN shell
perl -MCPAN -e shell install PICA::Record
For more information on module installation, please visit the detailed CPAN module installation guide.