NAME

MARC::Record::Generic - Convert between MARC::Record objects and native Perl primitives.

SYNOPSIS

use MARC::Record::Generic;

my $record = MARC::Record->new_from_generic( $marcdata );
$marcdata = $record->as_generic;

DESCRIPTION

This module provides routines for converting between MARC::Record objects and Perl native data in the format of:

my $marcdata = {
  leader => '01109cam a2200349 a 4500',
  fields => [
    '001',
    '   89009461 //r92',
    '005',
    '19991006093052.0',
    '008',
    '991006s1989    nyuaf   bb    00110aeng  ',
    '010',
    {
      subfields => [
        'a',
        '89009461 //r92'
      ],
      ind1 => ' ',
      ind2 => ' '
    },
    '010',
    ...
  ]
}

Data in this format can be used for a number of purposes, but the principle intention is to make MARC data amenable to serializing into JSON, YAML, etc. Field and subfield order is preserved. Multiple instances of either are also allowed. No effort is made to ensure that the MARC contents are sensible or follow a particular standard.

INTERFACE

MARC::Record::Generic injects two subroutines into the MARC::Record namespace.

  • MARC::Record::as_generic( )

    An instance method for a MARC::Record object. Returns the objects values as Perl primitives.

  • MARC::Record::new_from_generic( $marcdata )

    A package method of MARC::Record which applies the values contained in $data to the object which it returns.

SEE ALSO

Code inspired by Frederic Demians' MARC::Moose::Formater::JSON.

Format inspired by http://dilettantes.code4lib.org/blog/2010/09/a-proposal-to-serialize-marc-in-json

AUTHOR

Clay Fouts <cfouts@khephera.net>

COPYRIGHT & LICENSE

Copyright (c) 2012 PTFS/LibLime

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