better support for ISIS files with null pointers (it will warn and not die)
[Biblio-Isis] / lib / Biblio / Isis.pm
index 2690020..ba32c69 100644 (file)
@@ -9,7 +9,7 @@ use Data::Dumper;
 BEGIN {
        use Exporter ();
        use vars qw ($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
-       $VERSION     = 0.11;
+       $VERSION     = 0.13;
        @ISA         = qw (Exporter);
        #Give a hoot don't pollute, do not export more than needed by default
        @EXPORT      = qw ();
@@ -147,7 +147,10 @@ sub new {
        push @must_exist, "fdt" if ($self->{read_fdt});
 
        foreach my $ext (@must_exist) {
-               croak "missing ",uc($ext)," file in ",$self->{isisdb} unless ($self->{$ext."_file"});
+               unless ($self->{$ext."_file"}) {
+                       carp "missing ",uc($ext)," file in ",$self->{isisdb};
+                       return;
+               }
        }
 
        print STDERR "## using files: ",join(" ",@isis_files),"\n" if ($self->{debug});
@@ -261,7 +264,15 @@ sub fetch {
 
        # read XRFMFB abd XRFMFP
        read($self->{'fileXRF'}, $buff, 4);
-       my $pointer=unpack("V",$buff) || croak "pointer is null";
+       my $pointer=unpack("V",$buff);
+       if (! $pointer) {
+               if ($self->{include_deleted}) {
+                       return;
+               } else {
+                       warn "pointer for MFN $mfn is null\n";
+                       return;
+               }
+       }
 
        # check for logically deleted record
        if ($pointer & 0x80000000) {
@@ -390,7 +401,7 @@ sub to_ascii {
 
        my $mfn = shift || croak "need MFN";
 
-       my $rec = $self->fetch($mfn);
+       my $rec = $self->fetch($mfn) || return;
 
        my $out = "0\t$mfn";
 
@@ -458,7 +469,7 @@ sub to_hash {
        # init record to include MFN as field 000
        my $rec = { '000' => [ $mfn ] };
 
-       my $row = $self->fetch($mfn);
+       my $row = $self->fetch($mfn) || return;
 
        foreach my $k (keys %{$row}) {
                foreach my $l (@{$row->{$k}}) {