Subject: | Multiple values bug in subfield function for MARC::Record |
Date: | Mon, 09 Apr 2012 16:35:16 -0400 |
To: | Bugs in MARC-Record via RT <bug-MARC-Record [...] rt.cpan.org> |
From: | "Chris Cooke, Contractor, Code 5596" <chris.cooke.ctr [...] nrl.navy.mil> |
There is a bug in MARC::Record when you have multiple values for a field,
such as mutliple ISBNs (field 020). The subfield function only returns the
first value, even in an array context. But the field function correctly
returns an array.
I parsed a file using MARC::File::USMARC, and then for a sample record, did
this code:
print "subfield test\n";
@isbns = $marc->subfield('020', 'a');
foreach my $isbn (@isbns) {
print " isbn from subfield function: $isbn\n";
}
print " there were " . scalar(@isbns) . " isbns from subfield
function\n";
print "field test\n";
@isbns = $marc->field('020');
foreach my $isbn (@isbns) {
print " isbn from field function: " . $isbn->subfield('a') . "\n";
}
And it printed this result:
subfield test
isbn from subfield function: 9781574443066
there were 1 isbns from subfield function
field test
isbn from field function: 9781574443066
isbn from field function: 1574443062 (alk. paper)
there were 2 isbns from field function
As you can see, the subfield function threw away my second ISBN.
-Chris