From: Shawn Boyette Date: Tue, 5 Aug 2008 19:17:30 +0000 (+0000) Subject: * patched up main loop, getting rid of spurious $batch->next call warnings X-Git-Url: http://git.equinoxoli.org/?p=migration-tools.git;a=commitdiff_plain;h=e81710652900633ffa5a86cb08b0562d0511bc61 * patched up main loop, getting rid of spurious $batch->next call warnings * cleanup, readability --- diff --git a/fingerprints.pl b/fingerprints.pl index acc2e96..5d61ab8 100755 --- a/fingerprints.pl +++ b/fingerprints.pl @@ -9,7 +9,7 @@ use MARC::Field; use Unicode::Normalize; my $count = 0; -my $which = shift; +my $runtype = shift; my $id_tag = shift; my $id_subfield = shift; @@ -26,10 +26,8 @@ for my $file (@ARGV) { $batch->strict_off(); $batch->warnings_off(); - my $record = 1; - while ( $record ) { + while ( my $record = $batch->next ) { $count++; - $record = $batch->next(); my $id = $record->field($id_tag); if (!$id) { @@ -47,6 +45,7 @@ for my $file (@ARGV) { $my_008 = $my_008->as_string() if ($my_008); my $date1 = substr($my_008,7,4) if ($my_008); my $date2 = substr($my_008,11,4) if ($my_008); + my $item_form; if ( $record_type =~ /[gkroef]/ ) { # MAP, VIS $item_form = substr($my_008,29,1) if ($my_008); @@ -78,9 +77,11 @@ for my $file (@ARGV) { } my $issn = $record->field('022'); - if ( $issn ) { $issn = $issn->subfield('a'); } + $issn = $issn->subfield('a') if $issn; + my $lccn = $record->field('010'); - if ( $lccn ) { $lccn = $lccn->subfield('a'); } + $lccn = $lccn->subfield('a') if $lccn; + my $author; if ($record->field('100')) { $author = $record->field('100')->subfield('a'); } @@ -90,10 +91,13 @@ for my $file (@ARGV) { $author = $record->field('111')->subfield('a') if ($record->field('111')); } + my $desc = $record->field('300'); if ( $desc ) { $desc = $desc->subfield('a'); } + my $pages; if (defined $desc and $desc =~ /(\d+)/) { $pages = $1; } + my $my_260 = $record->field('260'); my $publisher = $my_260->subfield('b') if ( $my_260 ); my $pubyear = $my_260->subfield('c') if ( $my_260 ); @@ -103,6 +107,7 @@ for my $file (@ARGV) { else { $pubyear = ''; } } + my $edition = $record->field('250'); if ( $edition ) { $edition = $edition->subfield('a'); } @@ -135,7 +140,7 @@ for my $file (@ARGV) { # The same thing goes for some other fields. if ($item_form && ($date1 =~ /\d\d\d\d/) && $record_type && $bib_lvl && $title) { - if ($which eq "primary") { + if ($runtype eq "primary") { print STDOUT join("\t",$id,$item_form,$date1,$record_type,$bib_lvl,$title) ,"\n";