13 |
|
|
14 |
use Data::Dumper; |
use Data::Dumper; |
15 |
|
|
16 |
|
my ($have_biblio_isis, $have_openisis) = (0,0); |
17 |
|
|
18 |
|
eval "use Biblio::Isis 0.13;"; |
19 |
|
unless ($@) { |
20 |
|
$have_biblio_isis = 1 |
21 |
|
} else { |
22 |
|
eval "use OpenIsis;"; |
23 |
|
$have_openisis = 1 unless ($@); |
24 |
|
} |
25 |
|
|
26 |
#my $LOOKUP_REGEX = '\[[^\[\]]+\]'; |
#my $LOOKUP_REGEX = '\[[^\[\]]+\]'; |
27 |
#my $LOOKUP_REGEX_SAVE = '\[([^\[\]]+)\]'; |
#my $LOOKUP_REGEX_SAVE = '\[([^\[\]]+)\]'; |
28 |
my $LOOKUP_REGEX = 'lookup{[^\{\}]+}'; |
my $LOOKUP_REGEX = 'lookup{[^\{\}]+}'; |
217 |
$log->info("reading ISIS database '",$arg->{'filename'},"'"); |
$log->info("reading ISIS database '",$arg->{'filename'},"'"); |
218 |
$log->debug("isis code page: $code_page"); |
$log->debug("isis code page: $code_page"); |
219 |
|
|
|
my $use_openisis = 1; |
|
|
|
|
|
eval { use IsisDB 0.06; }; |
|
|
$use_openisis = 0 unless ($@); |
|
|
|
|
220 |
my ($isis_db,$maxmfn); |
my ($isis_db,$maxmfn); |
221 |
|
|
222 |
if ($use_openisis) { |
if ($have_openisis) { |
223 |
use OpenIsis; |
$log->debug("using OpenIsis perl bindings"); |
224 |
$isis_db = OpenIsis::open($arg->{'filename'}); |
$isis_db = OpenIsis::open($arg->{'filename'}); |
225 |
$maxmfn = OpenIsis::maxRowid( $isis_db ) || 1; |
$maxmfn = OpenIsis::maxRowid( $isis_db ) || 1; |
226 |
} else { |
} elsif ($have_biblio_isis) { |
227 |
$isis_db = new IsisDB( |
$log->debug("using Biblio::Isis"); |
228 |
|
use Biblio::Isis; |
229 |
|
$isis_db = new Biblio::Isis( |
230 |
isisdb => $arg->{'filename'}, |
isisdb => $arg->{'filename'}, |
231 |
include_deleted => 1, |
include_deleted => 1, |
232 |
hash_filter => sub { |
hash_filter => sub { |
236 |
}, |
}, |
237 |
); |
); |
238 |
$maxmfn = $isis_db->{'maxmfn'}; |
$maxmfn = $isis_db->{'maxmfn'}; |
239 |
|
} else { |
240 |
|
$log->logdie("Can't find supported ISIS library for perl. I suggent that you install Bilbio::Isis from CPAN."); |
241 |
} |
} |
242 |
|
|
243 |
|
|
252 |
|
|
253 |
$maxmfn = $startmfn + $self->{limit_mfn} if ($self->{limit_mfn}); |
$maxmfn = $startmfn + $self->{limit_mfn} if ($self->{limit_mfn}); |
254 |
|
|
255 |
$log->info("processing ",($maxmfn-$startmfn)." records using ",( $use_openisis ? 'OpenIsis' : 'IsisDB')); |
$log->info("processing ",($maxmfn-$startmfn)." records using ",( $have_openisis ? 'OpenIsis' : 'Biblio::Isis')); |
256 |
|
|
257 |
|
|
258 |
# read database |
# read database |
263 |
|
|
264 |
my $rec; |
my $rec; |
265 |
|
|
266 |
if ($use_openisis) { |
if ($have_openisis) { |
267 |
|
|
268 |
# read record using OpenIsis |
# read record using OpenIsis |
269 |
my $row = OpenIsis::read( $isis_db, $mfn ); |
my $row = OpenIsis::read( $isis_db, $mfn ); |
289 |
} |
} |
290 |
} |
} |
291 |
|
|
292 |
} else { |
} elsif ($have_biblio_isis) { |
293 |
$rec = $isis_db->to_hash($mfn); |
$rec = $isis_db->to_hash($mfn); |
294 |
|
} else { |
295 |
|
$log->logdie("hum? implementation missing?"); |
296 |
} |
} |
297 |
|
|
298 |
$log->confess("record $mfn empty?") unless ($rec); |
$log->confess("record $mfn empty?") unless ($rec); |