"Empty contents" message not fatal, now given only as warning
[www.energie.vellum.cz.git] / obsah_init.pl
index 5668855..89d40a7 100755 (executable)
@@ -52,13 +52,18 @@ sub flush_month
 {
        $_=$contents;
        return if !defined $_;
-       die "Empty contents".&where() if !$_;
-       tr/ \t\n/  \n/s;
-       s/([\001\n]) | ([\002\n])/$1$2/g;
-       s/\nstrana \.\.\. ([\d ,]+\002)/\003$1/g;
-       die "Page marker not found somewhere in this month".&where() if (/\001[^\003]*\002/);
-       tr/\002//d;
-       $insert_tb_obsah->execute($year,$month,$month_last,substr($_,1)) or die "SQL insert failure: $!";
+       if (!$_) {
+               print("Empty contents".&where()."!\n");
+               }
+       else {
+               tr/ \t\n/  \n/s;
+               s/([\001\n]) | ([\002\n])/$1$2/g;
+               s/\nstrana \.\.\. ([\d ,]+\002)/\003$1/g;
+               die "Page marker not found somewhere in this month".&where() if (/\001[^\003]*\002/);
+               tr/\002//d;
+               $_=substr($_,1);
+               }
+       $insert_tb_obsah->execute($year,$month,$month_last,$_) or die "SQL insert failure: $!";
        undef $year,$month;
        undef $contents;
 }