LibreCat / Catmandu-MARC

Catmandu modules for working with MARC data
https://metacpan.org/release/Catmandu-MARC
Other
8 stars 10 forks source link

marc_map() of subfields '0' doesn't work #46

Closed jorol closed 7 years ago

jorol commented 7 years ago

Catmandu v1.0302 Catmandu::MARC v1.01

marc_map() of subfields with code '0' doesn't work any more (worked with Catmandu::MARC v.0.219).

Example (see gist https://gist.githubusercontent.com/jorol/2779295e397394d06d3d596310bef59d/raw/4f2ab8d4fc0bdf1af2fbc88802548f9b56beb7f6/subf_zero.t):

#!/usr/bin/perl

use strict;
use warnings;

use Catmandu;
use Catmandu::Importer::MARC;
use Test::More;

my $mrc
    = '00093nam a2200037 c 45001000055000001 aPoe, Curtis0(DE-601)7303424090(DE-588)1028093195';

my $fixer = Catmandu::Fix->new(
    fixes => [
        'marc_map(100,subf_all,-join => "~")',
        'marc_map(100a,subf_a)',
        'marc_map(1000,subf_zero,-join => "~")'
    ]
);
my $importer = Catmandu::Importer::MARC->new( file => \$mrc, type => 'ISO' );
my $record = $fixer->fix($importer)->first;

is( $record->{subf_all},
    'Poe, Curtis~(DE-601)730342409~(DE-588)1028093195',
    'all subfields'
);
is( $record->{subf_a}, 'Poe, Curtis', 'subfield a' );
is( $record->{subf_zero}, '(DE-601)730342409~(DE-588)1028093195',
    'subfields 0' );

done_testing;
jorol commented 7 years ago

fixed with #47

phochste commented 7 years ago

Merge the changes. Thanks. This was a bit of coding nastiness on my side