check year validity and report invalid_year in $skip
authorDobrica Pavlinusic <dpavlin@rot13.org>
Sun, 24 Nov 2013 22:19:16 +0000 (23:19 +0100)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Sun, 24 Nov 2013 22:19:16 +0000 (23:19 +0100)
html.pl

diff --git a/html.pl b/html.pl
index ef041d2..84d54e2 100755 (executable)
--- a/html.pl
+++ b/html.pl
@@ -155,7 +155,12 @@ while( my $row = $sth_select_authors->fetchrow_hashref ) {
 
         if ($elt->localname eq 'controlfield') {
                        if ( $tag eq '008' ) {
-                                $biblio_year->{ $row->{biblionumber} } = $data->{year} = substr($elt->textContent, 7, 4 );
+                               my $year = substr($elt->textContent, 7, 4 );
+                               if ( $year !~ m/^\d+$/ ) {
+                                       $year = 0;
+                                       push @{ $skip->{invalid_year} }, $row->{biblionumber};
+                               }
+                               $biblio_year->{ $row->{biblionumber} } = $data->{year} = $year;
                        }
                        next;
         } elsif ($elt->localname eq 'datafield') {