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


MARC-Fast documentation  | view source Contained in the MARC-Fast distribution.

Index


NAME

Top

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

SYNOPSIS

Top

  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

Top

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

Top

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

Top

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

Top

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

COPYRIGHT

Top

SEE ALSO

Top

Biblio::Isis, perl(1).


MARC-Fast documentation  | view source Contained in the MARC-Fast distribution.