Hi,
I have a peace of perl code which is using curl to download GRIB files.
Coming from a Visual Basic and Java backgoud I have just limited knowledge about what exactly is going on in the code below.
Especially the curl usage is very cryptographic for me...
I would highly apprechiate if someone provides an explaination what is going on in which line.
Thanks!
I have a peace of perl code which is using curl to download GRIB files.
Coming from a Visual Basic and Java backgoud I have just limited knowledge about what exactly is going on in the code below.
Especially the curl usage is very cryptographic for me...
I would highly apprechiate if someone provides an explaination what is going on in which line.
Perl:
$range="";
$lastfrom='';
$lastto=-100;
while (<STDIN>) {
chomp;
$from='';
/:range=([0-9]*)/ && do {$from=$1};
$to='';
/:range=[0-9]*-([0-9]*)/ && do {$to=$1};
if ($lastto+1 == $from) {
$lastto = $to;
}
elsif ($lastto ne $to) {
if ($lastfrom ne '') {
if ($range eq '') { $range="$lastfrom-$lastto"; }
else { $range="$range,$lastfrom-$lastto"; }
}
$lastfrom=$from;
$lastto=$to;
}
}
if ($lastfrom ne '') {
if ($range eq '') { $range="$lastfrom-$lastto"; }
else { $range="$range,$lastfrom-$lastto"; }
}
unlink $file;
if ($range ne "") {
$err=system("$curl -f -v -s -r \"$range\" $url -o $file.tmp");
$err = $err >> 8;
if ($err != 0) {
print STDERR "error in getting file $err\n";
sleep(20);
exit $err;
}
if (! rename "$file.tmp", "$file") {
sleep(30);
}
}
else {
sleep(10);
print STDERR "No download!\n";
sleep(30);
exit 8;
}
Thanks!