Don't go stampeding towards the location subfields!
authordbs <dbs@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 2 Jun 2009 13:54:04 +0000 (13:54 +0000)
committerdbs <dbs@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 2 Jun 2009 13:54:04 +0000 (13:54 +0000)
Return gracefully if the MFHD record contains no 852 field, rather than erroring out

git-svn-id: svn://svn.open-ils.org/ILS/trunk@13287 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Utils/MFHDParser.pm

index ad85797..eb9998a 100644 (file)
@@ -54,7 +54,7 @@ Returns a Perl hash containing fields of interest from the MFHD record
 sub mfhd_to_hash {
        my ($self, $mfhd_xml) = @_;
 
-       my $location;
+       my $location = '';
        my $holdings = [];
        my $supplements = [];
        my $indexes = [];
@@ -68,9 +68,11 @@ sub mfhd_to_hash {
        my $marc = MARC::Record->new_from_xml($mfhd_xml);
        my $mfhd = MFHD->new($marc);
 
-       foreach my $subfield_ref ($marc->field('852')->subfields) {
-               my ($subfield, $data) = @$subfield_ref;
-               $location .= $data . " -- ";
+       foreach my $field ($marc->field('852')) {
+               foreach my $subfield_ref ($field->subfields) {
+                       my ($subfield, $data) = @$subfield_ref;
+                       $location .= $data . " -- ";
+               }
        }
        $location =~ s/ -- $//;