Dobrica Pavlinusic > MARC-Fast-0.11 > MARC::Fast

Download:
MARC-Fast-0.11.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
View/Report Bugs
Module Version: 0.11   Source   Latest Release: MARC-Fast-0.12

NAME ^

MARC::Fast - Very fast implementation of MARC database reader

SYNOPSIS ^

  use MARC::Fast;

  my $marc = new MARC::Fast(
        marcdb => 'unimarc.iso',
  );

  foreach my $mfn ( 1 .. $marc->count ) {
        print $marc->to_ascii( $mfn );
  }

For longer example with command line options look at "dump_fastmarc.pl" in scripts

DESCRIPTION ^

This is very fast alternative to MARC and MARC::Record modules.

It's is also very subtable for random access to MARC records (as opposed to sequential one).

METHODS ^

new

Read MARC database

  my $marc = new MARC::Fast(
        marcdb => 'unimarc.iso',
        quiet => 0,
        debug => 0,
        assert => 0,
        hash_filter => sub {
                my ($t, $record_number) = @_;
                $t =~ s/foo/bar/;
                return $t;
        },
  );

count

Return number of records in database

  print $marc->count;

fetch

Fetch record from database

  my $hash = $marc->fetch(42);

First record number is 1

last_leader

Returns leader of last record fetched

  print $marc->last_leader;

Added in version 0.08 of this module, so if you need it use:

  use MARC::Fast 0.08;

to be sure that it's supported.

to_hash

Read record with specified MFN and convert it to hash

  my $hash = $marc->to_hash( $mfn, include_subfields => 1, );

It has ability to convert characters (using hash_filter) from MARC database before creating structures enabling character re-mapping or quick fix-up of data.

This function returns hash which is like this:

  '200' => [
             {
               'i1' => '1',
               'i2' => ' '
               'a' => 'Goa',
               'f' => 'Valdo D\'Arienzo',
               'e' => 'tipografie e tipografi nel XVI secolo',
             }
           ],

This method will also create additional field 000 with MFN.

to_ascii

  print $marc->to_ascii( 42 );

UTF-8 ENCODING ^

This module does nothing with encoding. But, since MARC format is byte oriented even when using UTF-8 which has variable number of bytes for each character, file is opened in binary mode.

As a result, all scalars recturned to perl don't have utf-8 flag. Solution is to use hash_filter and Encode to decode utf-8 encoding like this:

  use Encode;

  my $marc = new MARC::Fast(
        marcdb => 'utf8.marc',
        hash_filter => sub {
                Encode::decode( 'utf-8', $_[0] );
        },
  );

This will affect to_hash, but fetch will still return binary representation since it doesn't support hash_filter.

AUTHOR ^

        Dobrica Pavlinusic
        CPAN ID: DPAVLIN
        dpavlin@rot13.org
        http://www.rot13.org/~dpavlin/

COPYRIGHT ^

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

The full text of the license can be found in the LICENSE file included with this module.

SEE ALSO ^

Biblio::Isis, perl(1).

syntax highlighting: