From 8702212d16c05a4fe09d73baa7967416ab390cd5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?S=C3=A9bastien=20Hinderer?= Date: Thu, 3 Sep 2009 20:11:09 +0200 Subject: [PATCH] Get rid of a few warnings in the bulkmarcimport script: C4/Biblio.pm, hunks #1, #2: a warning occurring in NoZebra configurations. C4/Biblio.pm hunk #3: warning occurring in Unimarc MARC flavour. misc/migration_tools/bulkmarcimport.pl hunk #1: warning occurring when no default format is specified on command-line with -m switch. Signed-off-by: Galen Charlton Signed-off-by: Henri-Damien LAURENT --- C4/Biblio.pm | 10 +++++----- misc/migration_tools/bulkmarcimport.pl | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/C4/Biblio.pm b/C4/Biblio.pm index 8fa138919b..778fd1cbda 100755 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -2646,7 +2646,8 @@ sub _AddBiblioNoZebra { foreach (split / /,$line) { next unless $_; # skip empty values (multiple spaces) # if the entry is already here, improve weight - if ($result{'__RAW__'}->{"$_"} =~ /$biblionumber,\Q$title\E\-(\d+);/) { + my $tmpstr = $result{'__RAW__'}->{"$_"} || ""; + if ($tmpstr =~ /$biblionumber,\Q$title\E\-(\d+);/) { my $weight=$1+1; $result{'__RAW__'}->{"$_"} =~ s/$biblionumber,\Q$title\E\-(\d+);//; $result{'__RAW__'}->{"$_"} .= "$biblionumber,$title-$weight;"; @@ -2657,7 +2658,7 @@ sub _AddBiblioNoZebra { # it exists if ($existing_biblionumbers) { $result{'__RAW__'}->{"$_"} =$existing_biblionumbers; - my $weight=$1+1; + my $weight = ($1 ? $1 : 0) + 1; $result{'__RAW__'}->{"$_"} =~ s/$biblionumber,\Q$title\E\-(\d+);//; $result{'__RAW__'}->{"$_"} .= "$biblionumber,$title-$weight;"; # create a new ligne for this entry @@ -3248,9 +3249,8 @@ sub ModBiblioMarc { # deal with UNIMARC field 100 (encoding) : create it if needed & set encoding to unicode if ( $encoding eq "UNIMARC" ) { - my $string; - if ( length($record->subfield( 100, "a" )) == 35 ) { - $string = $record->subfield( 100, "a" ); + my $string = $record->subfield( 100, "a" ); + if ( ($string) && ( length($record->subfield( 100, "a" )) == 35 ) ) { my $f100 = $record->field(100); $record->delete_field($f100); } diff --git a/misc/migration_tools/bulkmarcimport.pl b/misc/migration_tools/bulkmarcimport.pl index dc4a3b0619..354c5d98a4 100755 --- a/misc/migration_tools/bulkmarcimport.pl +++ b/misc/migration_tools/bulkmarcimport.pl @@ -131,7 +131,7 @@ print "Characteristic MARC flavour: $marcFlavour\n" if $verbose; my $starttime = gettimeofday; my $batch; my $fh = IO::File->new($input_marc_file); # don't let MARC::Batch open the file, as it applies the ':utf8' IO layer -if ($format =~ /XML/i) { +if (defined $format && $format =~ /XML/i) { # ugly hack follows -- MARC::File::XML, when used by MARC::Batch, # appears to try to convert incoming XML records from MARC-8 # to UTF-8. Setting the BinaryEncoding key turns that off -- 2.39.5