|
|
| |
require "flush.pl"; | require "flush.pl"; |
use Getopt::Long; | use Getopt::Long; |
|
use File::Temp qw(tempdir); |
|
my $tmpdir = tempdir(TEMPDIR => 1, CLEANUP => 1 ); |
|
|
$/="\r\n"; # we work with dos files | $/="\r\n"; # we work with dos files |
| |
# | # |
|
|
$country="GB"; | $country="GB"; |
} | } |
| |
# All logging information goes into this file |
|
$logfile = "/tmp/langen2kvtml.log"; |
|
open(LOG, ">$logfile") || die "Cannot create $logfile: $!"; |
|
|
|
&printflush(STDOUT,"Waiting for generating files ...\n"); | &printflush(STDOUT,"Waiting for generating files ...\n"); |
$tmp1=$#ARGV+1; | $tmp1=$#ARGV+1; |
&printflush(STDOUT,"... $tmp1 files given via command line ...\n"); | &printflush(STDOUT,"... $tmp1 files given via command line ...\n"); |
|
|
if ($proxy) { | if ($proxy) { |
&printflush(STDOUT,"... using proxy service $proxy ...\n"); | &printflush(STDOUT,"... using proxy service $proxy ...\n"); |
} | } |
`lwp-request $proxy http://www.vokabeln.de/files/Voc-$country.zip >/tmp/Voc-$country.zip`; |
`lwp-request $proxy http://www.vokabeln.de/files/Voc-$country.zip >$tmpdir/Voc-$country.zip`; |
# unzip -u update only! |
|
# unzip -o overwrite! |
|
`unzip -u /tmp/Voc-$country.zip >/tmp/unzip.log`; |
|
&printflush(STDOUT,"... updating Voc-$country.zip ...\n"); | &printflush(STDOUT,"... updating Voc-$country.zip ...\n"); |
$/="\n"; # we work with a unix file | $/="\n"; # we work with a unix file |
open(ZIP,"</tmp/unzip.log"); |
# unzip -u update only! |
|
open(ZIP,"unzip -u $tmpdir/Voc-$country.zip |"); |
while(<ZIP>) { | while(<ZIP>) { |
chomp; | chomp; |
if( /voc/ ) { | if( /voc/ ) { |
|
|
} | } |
} | } |
close(ZIP); | close(ZIP); |
unlink("/tmp/unzip.log"); |
|
$/="\r\n"; # we work with a dos file | $/="\r\n"; # we work with a dos file |
} | } |
| |
for my $file (@res, @ARGV) { | for my $file (@res, @ARGV) { |
$vocfile = $file; | $vocfile = $file; |
&printflush(LOG,"... generating \"$kvtfile\"...\n"); |
|
$lang = ""; # initially unset | $lang = ""; # initially unset |
$filestage = 0; # file stage | $filestage = 0; # file stage |
&process_vocfile($vocfile); | &process_vocfile($vocfile); |
} | } |
print STDERR "...\tAll Complete.\n"; | print STDERR "...\tAll Complete.\n"; |
&printflush(LOG,"\nAll Complete.\n"); |
|
close(LOG); |
|
| |
exit; | exit; |
| |