in reply to Zip file from WWW::Mechanize

What happens when you try to pull the zip file from a browser? Is it possible that the zip file is corrupted as it is being sent from the web server itself?

--MidLifeXis

The tomes, scrolls etc are dusty because they reside in a dusty old house, not because they're unused. --hangon in this post

Replies are listed 'Best First'.
Re^2: Zip file from WWW::Mechanize
by jck000 (Novice) on Mar 23, 2009 at 17:32 UTC
    It works properly from a browser. Here are file listings of the same file: -rw-r--r-- 1 jack3 jack3 337991 2009-03-19 23:48 auto_20090318_0610.zip -rw-r--r-- 1 jack3 jack3 631747 2009-03-20 00:03 report.zip Jack
      The newer file is twice the size. What's the output of
      od -c auto_20090318_0610.zip | head -n 4
      and
      od -c report.zip | head -n 4
        jack3:/usr/genoais/aiq/aiq/bin$ od -c auto_20090318_0610.zip | head -n + 4 0000000 P K 003 004 024 \0 \0 \0 \b \0 a I s : S +F 0000020 215 200 C & 005 \0 345 233 * \0 026 \0 \0 \0 a +u 0000040 t o _ 2 0 0 9 0 3 1 8 _ 0 6 1 +0 0000060 . c s v 344 275 [ s 333 310 226 . 370 > 021 36 +3 jack3:/usr/genoais/aiq/aiq/bin$ od -c report.zip | head -n 4 0000000 P K 003 004 024 \0 \0 \0 \b \0 a I s : S +F 0000020 357 277 275 357 277 275 C & 005 \0 357 277 275 357 277 27 +5 0000040 * \0 026 \0 \0 \0 a u t o _ 2 0 0 9 +0 0000060 3 1 8 _ 0 6 1 0 . c s v 357 277 275 35 +7

      Please include some code; preferably the smallest amount possible that still reproduces your problem. Perhaps there is something inherently wrong with the code that extra eyes may see.

      --MidLifeXis

      The tomes, scrolls etc are dusty because they reside in a dusty old house, not because they're unused. --hangon in this post

        $mech = WWW::Mechanize->new(); $mech->quiet(0); $mech->agent_alias( 'Windows IE 6' ); $r = HTTP::Request->new( POST => "https://my.bandwidth.com" ); $r->content("/portal/"); $mech->request($r)->content; ... ... ... $matches[0] =~ /href.*?=.*?\"(.*?)\"/; print "Link: $1\n"; $getreport="https://my.bandwidth.com/portal/Members/Voice/$1"; $mech->get($getreport); $content=$mech->content; save_to_file($content, 'decode.zip', 1); sub save_to_file { my $xcontent = shift; my $filename = shift; open (LOG, ">$filename"); binmode LOG; print LOG $xcontent; close(LOG); }