From 3199d032e5315e7cd3ef78b6fac539040e6f5f9b Mon Sep 17 00:00:00 2001 From: Colin Campbell Date: Thu, 20 Aug 2009 11:12:57 +0100 Subject: [PATCH] Avoid numeric comparisons with leading zeroes Numbers in perl with leading zeros are interpreted in octal Ensure that comparisons are done using string operators or where appropriate use the MARC::Field method Signed-off-by: Galen Charlton --- C4/Record.pm | 2 +- cataloguing/addbiblio.pl | 2 +- misc/batchCompareMARCvsFrameworks.pl | 2 +- misc/migration_tools/bulkmarcimport.pl | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/C4/Record.pm b/C4/Record.pm index 2ac9ecaaf3..2be47519e0 100644 --- a/C4/Record.pm +++ b/C4/Record.pm @@ -381,7 +381,7 @@ sub html2marcxml { $marcxml.="@$values[$i]\n"; $first=1; # rest of the fixed fields - } elsif (@$tags[$i] < 010) { #FIXME: <10 was the way it was, there might even be a better way + } elsif (@$tags[$i] lt '010') { # don't compare numerically 010 == 8 $marcxml.="@$values[$i]\n"; $first=1; } else { diff --git a/cataloguing/addbiblio.pl b/cataloguing/addbiblio.pl index 8067a26873..b974d28374 100755 --- a/cataloguing/addbiblio.pl +++ b/cataloguing/addbiblio.pl @@ -665,7 +665,7 @@ sub build_tabs ($$$$$) { fixedfield => $tag < 10?1:0, random => CreateKey, ); - if ($tag >= 010){ # no indicator for theses tag + if ($tag >= 10){ # no indicator for 00x tags $tag_data{indicator1} = format_indicator($field->indicator(1)), $tag_data{indicator2} = format_indicator($field->indicator(2)), } diff --git a/misc/batchCompareMARCvsFrameworks.pl b/misc/batchCompareMARCvsFrameworks.pl index e255602fd6..b0ed79736b 100755 --- a/misc/batchCompareMARCvsFrameworks.pl +++ b/misc/batchCompareMARCvsFrameworks.pl @@ -69,7 +69,7 @@ my $i=0; while ( my $record = $batch->next() ) { $i++; foreach my $MARCfield ($record->fields()) { - next if $MARCfield->tag()<=010; + next if $MARCfield->is_control_field(); # tag num < 10 if ($MARCfield) { foreach my $fields ($MARCfield->subfields()) { if ($fields) { diff --git a/misc/migration_tools/bulkmarcimport.pl b/misc/migration_tools/bulkmarcimport.pl index 2a48540130..b8f550066b 100755 --- a/misc/migration_tools/bulkmarcimport.pl +++ b/misc/migration_tools/bulkmarcimport.pl @@ -195,7 +195,7 @@ RECORD: while ( ) { next RECORD; } if (defined $idmapfl) { - if ($sourcetag < "010"){ + if ($sourcetag lt '010'){ if ($record->field($sourcetag)){ my $source = $record->field($sourcetag)->data(); printf(IDMAP "%s|%s\n",$source,$biblionumber); -- 2.39.5