For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > May 2006 > start of central directory not found, Corrupt zip file









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author start of central directory not found, Corrupt zip file
TheAnswer1313

2006-05-30, 7:00 pm

hi using perl i tried to download a couple of zip files. They worked
fine but when i went to unzip them, i got that error msg. I have
noticed that when i download the files manually, they are slightly
smaller then when i download them with the script. If anyone can help
me around this issue, it would be great appreciated.

#!/usr/bin/perl -w

use FileHandle;

use LWP::UserAgent;
$ua = LWP::UserAgent ->new;
$baseurl = "http://www.retrosheet.org/";

$league = 'ml';
for ($year = 00; $year <= 05; $year++) {
my $filename = '200' . $year . $league . '.zip';
my $url = $baseurl . '200' . $year . '/200' . $year . $league .
'.zip';
my $req = HTTP::Request ->new(GET => $url);
my $res = $ua ->request($req);

print STDERR "fetching $filename\n";

if ($res ->is_success) {
my $fh = new FileHandle ">$filename";
if (defined $fh) {
print $fh $res ->content;
$fh ->close;
} else {
print STDERR "could not open file $filename: $!\n";
}
}
else {
print STDERR $res ->status_line, "\n";
}
}

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com