);
## The type of a MARC record is found at position 06 of the leader
- my $typeofrecord = substr($leader, 6, 1);
+ my $typeofrecord = defined($leader) && length $leader >=6 ?
+ substr($leader, 6, 1): undef;
## ToDo: for books, field 008 positions 24-27 might have a few more
## hints
my %typehash;
## the ukmarc here is just a guess
- if ($intype eq "marc21" || $intype eq "ukmarc") {
+ if (! defined $intype) {
+ ## assume MARC21 as default
+ %typehash = %ustypehash;
+ }
+ elsif ($intype eq "marc21" || $intype eq "ukmarc") {
%typehash = %ustypehash;
}
elsif ($intype eq "unimarc") {
%typehash = %ustypehash;
}
- if (!exists $typehash{$typeofrecord}) {
+ if (!defined $typeofrecord || !exists $typehash{$typeofrecord}) {
print "TY - BOOK\r\n"; ## most reasonable default
warn ("no type found - assume BOOK") if $marcprint;
}