***ОБНОВЛЕНО КОД с функциональностью резюме* *как загрузить `decoded_content`
my $ua = LWP::UserAgent->new;
$ua->credentials('$ip:80', 'Realm', 'username', 'password');
my $response = $ua->mirror($url,$newfile);
if ($response->is_success) {
print "Download Successfull.";
}
else {
print "Error: " . $response->status_line;
}
** * ** * * *СТАРЫЙ КОД* ** * ** * ** * ** * ** * *
my $ua = LWP::UserAgent->new;
$ua->credentials('$ip:80', 'Realm', 'username', 'password');
my $response = $ua->get($url);
if ($response->is_success) {
print "Retrieved " .length($response->decoded_content) .
" bytes of data.";
}
else {
print "Error: " . $response->status_line;
}
open my $fh, '>encoding(UTF-8)', $tmp;
print {$fh} $response->decoded_content;
close $fh;
if (-e $tmp) {
my $filesize = (stat $tmp)[9];
my $origsize = $queue[$rec][1];
if ($filesize < $origsize) {
print "Resuming download";
******************************************
code for resuming the partly downloaded file...
*******************************************
}
else {
print "File downloaded correctly\n";
}
}
Как я новичок в Perl, может загрузить decoded_content
, хотя некоторые ошибки сохраняются. Необходимо возобновить загрузку файла, если у нас есть частичный файл.
Это был код, который я пробовал, но не могу знать, с чего начать, поэтому любые быстрые мысли в этом отношении действительно помогут. Пожалуйста, помогите по этому поводу.
Возможно, вам стоит начать читать книгу. Как насчет [этого] (http://www.amazon.com/Learning-Perl-Randal-L-Schwartz/dp/1449303587/ref=sr_1_1?ie=UTF8&qid=1337074010&sr=8-1) –
После прочтения вы можете [edit] (http://stackoverflow.com/posts/10597630/edit) ваш вопрос, чтобы соответствовать stackoverflow. –