X-Git-Url: http://dxcluster.net/gitweb/gitweb.cgi?a=blobdiff_plain;f=cmd%2Fdbimport.pl;h=a08e169346c83a55cd92b92bc55e52f0b6772828;hb=bb4e9b13809a5d4c4971c3286309d12fe0f82047;hp=55d5e6322c00c4975e7387f90f2ca02e89781049;hpb=9e2fbafcfdab1ee45e581524311f1a97ac41f6ad;p=spider.git diff --git a/cmd/dbimport.pl b/cmd/dbimport.pl index 55d5e632..a08e1693 100644 --- a/cmd/dbimport.pl +++ b/cmd/dbimport.pl @@ -22,8 +22,7 @@ my $count; open(IMP, $fn) or return (1, "Cannot open $fn $!"); while () { - chomp; - s/\r//g; + s/[\r\n]+$//g; if ($state == 0) { if (/^\&\&/) { $state = 0; @@ -31,14 +30,18 @@ while () { } $key = uc $_; $value = undef; - ++$state; + ++$state if $key; } elsif ($state == 1) { if (/^\&\&/) { if ($key =~ /^#/) { + } elsif ($key && $value) { + $db->putkey($key, $value); + $count++; } - $db->putkey($key, $value); $state = 0; - $count++; + next; + } elsif (/^\%\%/) { + $state = 0; next; } $value .= $_ . "\n"; @@ -46,5 +49,5 @@ while () { } close (IMP); -push @out, $self->msg('db10', $count, $db->name); +push @out, $self->msg('db10', $count, $fn, $db->name); return (1, @out);