Hi All,

I have created a script that downloads and uncompresses files from the web.
I am having problems with the inflate
process. Using the inflate command I have checked the status and it is set
to -3. Does anyone know what that means?

Thanks

Ron



use Compress::Zlib;
use HTTP::Request::Common;
use LWP::UserAgent;
use strict;
use warnings;
#use LWP::Debug qw(+);

my $path_info='f:/areacode';
my $logfile ='c:\temp\logfile.txt';
my @file_info = qw(cnutlzd.zip csutlzd.zip eautlzd.zip enutlzd.zip
esutlzd.zip wnutlzd.zip wputlzd.zip wsutlzd.zip);

############################################################################
# get the files from the web
############################################################################

my $ua = LWP::UserAgent->new;

$ua->agent('Mozilla/4.73');
open (LOG,">$logfile") or die "Can't open $logfile:$!\n";
foreach my $filename(@file_info)  {

my $request = HTTP::Request->new(GET =>
                "http://www.nanpa.com/nanp1/$filename";);

my $expected_length;
my $bytes_received = 0;

my $res = $ua->request($request,
                   sub {
                   my($chunk, $res) = @_;
                   $bytes_received += length($chunk);
                   unless (defined $expected_length) {
                      $expected_length = $request->content_length || 0;
                   }
                   if ($expected_length) {
                        printf LOG "%d%% - ",
                                  100 * $bytes_received / $expected_length;
                   }
                   print LOG "$bytes_received bytes received\n";
                   #print $chunk;
                   my $i = inflateInit() or die "Cannot create a inflation
stream\n" ;
                   my ($out, $status) = $i->inflate($chunk);
                      if (!defined($out))   {
                         warn "Something did not work right $status \n";

                      }
                   #print $out;

               });

  if ($res->is_success) {
     print LOG "downloaded $filename completed\n";
  }
  else {
     print LOG $res->status_line, "\n";
     exit (0);
  }
}
close LOG;

Reply via email to