use strict; use warnings; use WWW::Mechanize::Firefox; use Archive::Zip qw( :ERROR_CODES :CONSTANTS ); my $input = "file.txt"; open (my $FI, "<", $input) or die "Unable to open $input: $!\n"; #The following will eventually be reworked as hash my @kbnums; my @schools; for <$FI> { m/(KB\d*)\s(.*)/i; push(@kbnums, $1); push(@schools, $2); } my $url = 'https://start.of.url/'; my $mech = WWW::Mechanize::Firefox->new(); my $zip = Archive::Zip->new(); #$checkLoad was added to verify the file write was complete my $checkLoad = "some text that appears at bottom of page"; my $count = 0; for (@kbnums) { my $file = "$schools[$count].html"; my $addr = "$url$_"; my $attempts = 0; do { $mech->get($addr, synchronize=> 0, ':content_file' => $file); $attempts++; }while (!(grep($checkLoad, $file)) && ($attempts < 10) ); #Added this to verify the $file has the $checkLoad written grep($checkLoad, $file) ? print "$file - SUCCESS" : print "$file - FAIL"; $zip->addFile($file); $count++; } my $status = $zip->overwriteAs('EOC-triage.zip'); die "Unable to write Zip - $status : $!\n" if $status != AZ_OK; #### IO error: reading data : at C:\strawberry\perl\vendor\lib/Archive/Zip/NewFileMember.pm line 60 Archive::Zip::NewFileMember::_readRawChunk('Archive::Zip::NewFileMember=HASH(0x1af508c)', 'SCALAR(0x12db3a4)', 13787) called at C:\strawberry\perl\vendor\lib/Archive/Zip/Member.pm line 788 Archive::Zip::Member::readChunk('Archive::Zip::NewFileMember=HASH(0x1af508c)', 32768) called at C:\strawberry\perl\vendor\lib/Archive/Zip/Member.pm line 1063 Archive::Zip::Member::_writeData('Archive::Zip::NewFileMember=HASH(0x1af508c)', 'IO::File=GLOB(0x17d4484)') called at C:\strawberry\perl\vendor\lib/Archive/Zip/Member.pm line 1030 Archive::Zip::Member::_writeToFileHandle('Archive::Zip::NewFileMember=HASH(0x1af508c)', 'IO::File=GLOB(0x17d4484)', 1, 181272) called at C:\strawberry\perl\vendor\lib/Archive/Zip/Archive.pm line 402 Archive::Zip::Archive::writeToFileHandle('Archive::Zip::Archive=HASH(0x1afc8c4)', 'IO::File=GLOB(0x17d4484)') called at C:\strawberry\perl\vendor\lib/Archive/Zip/Archive.pm line 438 Archive::Zip::Archive::overwriteAs('Archive::Zip::Archive=HASH(0x1afc8c4)', 'EOC-triage.zip') called at gatherTriage2.pl line 51 Can't write to C:\DOCUME~1\user\LOCALS~1\Temp\prAo0rBZe7.zip at gatherTriage2.pl line 51 Uncaught exception from user code: Unable to Write Zip - 4 : at gatherTriage2.pl line 52 #### 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);