--- trunk2/lib/WebPAC.pm 2005/04/30 15:48:40 704 +++ trunk2/lib/WebPAC.pm 2005/07/13 22:34:52 705 @@ -13,6 +13,16 @@ use Data::Dumper; +my ($have_biblio_isis, $have_openisis) = (0,0); + +eval "use Biblio::Isis 0.13;"; +unless ($@) { + $have_biblio_isis = 1 +} else { + eval "use OpenIsis;"; + $have_openisis = 1 unless ($@); +} + #my $LOOKUP_REGEX = '\[[^\[\]]+\]'; #my $LOOKUP_REGEX_SAVE = '\[([^\[\]]+)\]'; my $LOOKUP_REGEX = 'lookup{[^\{\}]+}'; @@ -207,19 +217,16 @@ $log->info("reading ISIS database '",$arg->{'filename'},"'"); $log->debug("isis code page: $code_page"); - my $use_openisis = 1; - - eval { use IsisDB 0.06; }; - $use_openisis = 0 unless ($@); - my ($isis_db,$maxmfn); - if ($use_openisis) { - use OpenIsis; + if ($have_openisis) { + $log->debug("using OpenIsis perl bindings"); $isis_db = OpenIsis::open($arg->{'filename'}); $maxmfn = OpenIsis::maxRowid( $isis_db ) || 1; - } else { - $isis_db = new IsisDB( + } elsif ($have_biblio_isis) { + $log->debug("using Biblio::Isis"); + use Biblio::Isis; + $isis_db = new Biblio::Isis( isisdb => $arg->{'filename'}, include_deleted => 1, hash_filter => sub { @@ -229,6 +236,8 @@ }, ); $maxmfn = $isis_db->{'maxmfn'}; + } else { + $log->logdie("Can't find supported ISIS library for perl. I suggent that you install Bilbio::Isis from CPAN."); } @@ -243,7 +252,7 @@ $maxmfn = $startmfn + $self->{limit_mfn} if ($self->{limit_mfn}); - $log->info("processing ",($maxmfn-$startmfn)." records using ",( $use_openisis ? 'OpenIsis' : 'IsisDB')); + $log->info("processing ",($maxmfn-$startmfn)." records using ",( $have_openisis ? 'OpenIsis' : 'Biblio::Isis')); # read database @@ -254,7 +263,7 @@ my $rec; - if ($use_openisis) { + if ($have_openisis) { # read record using OpenIsis my $row = OpenIsis::read( $isis_db, $mfn ); @@ -280,8 +289,10 @@ } } - } else { + } elsif ($have_biblio_isis) { $rec = $isis_db->to_hash($mfn); + } else { + $log->logdie("hum? implementation missing?"); } $log->confess("record $mfn empty?") unless ($rec);