in reply to Zipping Files Help!
Your code doesn't run!
IO error: opening test.zip for read : No such file or directory ...
After created a test.zip, it still doesn't run.
format error: file is too shortOne otherthing, you don't want to open and close the log.txt within a loop!!!Move the open() and close() outside of the foreach
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Zipping Files Help!
by Anonymous Monk on Aug 31, 2011 at 04:08 UTC | |
| [reply] [d/l] |
|
Re^2: Zipping Files Help!
by Anonymous Monk on Aug 31, 2011 at 17:47 UTC | |
| [reply] [d/l] |
by Lotus1 (Vicar) on Aug 31, 2011 at 22:18 UTC | |
This version is trying to add a copy of 'log.txt' to the zip file each time the foreach loop iterates unless the file is already there. That means it adds it the first time and never again. It seems like you would want to just print to log.txt inside the foreach loop. Then after the foreach loop, close 'log.txt' and then call $zip->addFile('log.txt') then call writeToFileNamed. What is the purpose of the variable $zipped? You don't use it anywhere.
Is this intended to remove newlines? Why not use chomp? What does the output from this program look like? Is it creating test.zip at all? Does it contain files? I suggest you get rid of the 'show status' section at the end. If the program dies that won't run. And there is no use having the variable $flag. | [reply] [d/l] |