Get file size over HTTP
use LWP::UserAgent;
sub GetFileSize{
my $url=shift;
$ua = new LWP::UserAgent;
$ua->agent("Mozilla/5.0");
my $req = new HTTP::Request 'HEAD' => $url;
$req->header('Accept' => 'text/html');
$res = $ua->request($req);
if ($res->is_success) {
my $headers = $res->headers;
return $headers;
}
return 0;
}
$link='http://www.example.com/file.zip';
$header = GetFileSize($link);
print "File size: ".$header->content_length." bytes\n";
print "Last moified: ".localtime($header->last_modified)."\n";
exit;