Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

WWW::Mechanize::Firefox and Archive::Zip Issue

by bobross419 (Acolyte)
on Nov 07, 2011 at 00:46 UTC ( [id://936371]=perlquestion: print w/replies, xml ) Need Help??

bobross419 has asked for the wisdom of the Perl Monks concerning the following question:

Added spoilers so I don't break front page.

I'm working on a backup script for my department's triage list. Unfortunately, in order to pull the information I'm forced to use WWW::Mechanize::Firefox to go through the pages and pull down the information into .html files. Then I take all of the .html pages and put them into a .zip using Archive::Zip. Once this is done I'm using Mail::Outlook to send the .zip out to my group.

All seemed to be working fine for months until I suddenly received write errors when attempting to write to the .zip file. I started working on the code and uncovered a problem where the actual files aren't being put into the .zip, they are going in empty.

Here is the code I'm using with the email portion ripped out:

When I run the above code, one of three things will happen:

1) All of the HTML files are written correctly, the Zip file is created containing all of the files, but all of the files inside the zip are 0 size containing no data.

2) All of the HTML files are written correctly, the Zip file is created containing all of the files with their correct data.

3) I receive the following error:

From what I can determine, situation 1 occurs when I delete all of the old HTML and Zip files then try from scratch. Situations 2 and 3 seemingly occur at random whenever previously created HTML and Zip files are present.

Oddly, when I create a standalone script to go through all of the files using just Archive::Zip I don't seem to have this problem.

use strict; use warnings; use Archive::Zip qw( :ERROR_CODES :CONSTANTS); my @files = <*>; my $arch = Archive::Zip->new(); my $file = 'test.zip'; $arch->addFile($_) for (@files); my $status = $arch->overwriteAs($file);

I tried duplicating this in the original script without success.

I have a feeling that there is something simple that I'm overlooking, but I've gone through the code and through the Archive::Zip CPAN page quite a few times now without success. My other idea is that the html files aren't being written completely, but the grep seems to indicate otherwise.

Any help is appreciated.

Replies are listed 'Best First'.
Re: WWW::Mechanize::Firefox and Archive::Zip Issue
by bobross419 (Acolyte) on Nov 07, 2011 at 02:45 UTC
    Apparently the synchronize => 0 was causing the problems. I rewrote the script from scratch and everything works fine. I had originally added in the synchronize => 0 because nothing was happening... Of course something was happening, just very slowly.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://936371]
Approved by planetscape
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2024-04-20 02:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found