1 |
#!/usr/bin/perl -w |
#!/usr/bin/perl -w |
2 |
|
|
3 |
use strict; |
use strict; |
4 |
use Biblio::Isis; |
use Biblio::Isis 0.23; |
5 |
use Getopt::Std; |
use Getopt::Std; |
6 |
use Data::Dumper; |
use Data::Dumper; |
7 |
use XML::Simple; |
use XML::Simple; |
8 |
use Text::Iconv; |
use Text::Iconv; |
9 |
use Config::IniFiles; |
use Config::IniFiles; |
10 |
use Encode; |
use Encode; |
11 |
#use GDBM_File; |
use GDBM_File; |
12 |
use Fcntl; # for O_RDWR |
use Fcntl; # for O_RDWR |
13 |
use TDB_File; |
#use TDB_File; |
14 |
use Carp; |
use Carp; |
15 |
|
|
16 |
$|=1; |
$|=1; |
673 |
# create new lookup file |
# create new lookup file |
674 |
my $lookup_file = $cfg -> val($database, 'lookup_newfile'); # optional |
my $lookup_file = $cfg -> val($database, 'lookup_newfile'); # optional |
675 |
if ($lookup_file) { |
if ($lookup_file) { |
|
#tie %lhash, 'GDBM_File', $lookup_file, &GDBM_NEWDB, 0644; |
|
676 |
if (! -e $lookup_file) { |
if (! -e $lookup_file) { |
677 |
open(LOOKUP, "> $lookup_file") || die "can't create $lookup_file': $!"; |
open(LOOKUP, "> $lookup_file") || die "can't create $lookup_file': $!"; |
678 |
close(LOOKUP); |
close(LOOKUP); |
679 |
} |
} |
680 |
tie %lhash, 'TDB_File', $lookup_file, TDB_CLEAR_IF_FIRST, O_RDWR, 0644; |
tie %lhash, 'GDBM_File', $lookup_file, &GDBM_NEWDB, 0644; |
681 |
|
#tie %lhash, 'TDB_File', $lookup_file, TDB_CLEAR_IF_FIRST, O_RDWR, 0644; |
682 |
print STDERR "creating lookup file '$lookup_file'\n"; |
print STDERR "creating lookup file '$lookup_file'\n"; |
683 |
# delete memory cache for lookup file |
# delete memory cache for lookup file |
684 |
delete $cache->{lhash}; |
delete $cache->{lhash}; |
687 |
# open existing lookup file |
# open existing lookup file |
688 |
$lookup_file = $cfg -> val($database, 'lookup_open'); # optional |
$lookup_file = $cfg -> val($database, 'lookup_open'); # optional |
689 |
if ($lookup_file) { |
if ($lookup_file) { |
690 |
#tie %lhash, 'GDBM_File', $lookup_file, &GDBM_READER, 0644; |
tie %lhash, 'GDBM_File', $lookup_file, &GDBM_READER, 0644; |
691 |
tie %lhash, 'TDB_File', $lookup_file, TDB_DEFAULT, O_RDWR, 0644; |
#tie %lhash, 'TDB_File', $lookup_file, TDB_DEFAULT, O_RDWR, 0644; |
692 |
print STDERR "opening lookup file '$lookup_file'\n"; |
print STDERR "opening lookup file '$lookup_file'\n"; |
693 |
} |
} |
694 |
|
|
785 |
my $isis_db = $cfg -> val($database, 'isis_db') || die "$database doesn't have 'isis_db' defined!"; |
my $isis_db = $cfg -> val($database, 'isis_db') || die "$database doesn't have 'isis_db' defined!"; |
786 |
|
|
787 |
$import2cp = Text::Iconv->new($config->{isis_codepage},$codepage); |
$import2cp = Text::Iconv->new($config->{isis_codepage},$codepage); |
788 |
my $db = new Biblio::Isis( isisdb => $isis_db ); |
my $db = new Biblio::Isis( |
789 |
|
isisdb => $isis_db, |
790 |
|
join_subfields_with => ' ; ', |
791 |
|
); |
792 |
|
|
793 |
if (! $db) { |
if (! $db) { |
794 |
print STDERR "FATAL: can't read ISIS database: $isis_db, skipping...\n"; |
print STDERR "FATAL: can't read ISIS database: $isis_db, skipping...\n"; |