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

Hi all, I have written a programm which creates a number of files, a text file (which holds information on the quantity of files just produced) and places it on the server. What I would like to do now is zip or hqx those files. Can anybody help me with my problem?

Replies are listed 'Best First'.
Re: Creating Zip files
by neophyte (Curate) on Nov 17, 2000 at 16:58 UTC
    You might want to check out Archive-Zip from CPAN.

    neophyte

Re: Creating Zip files
by jeroenes (Priest) on Nov 17, 2000 at 17:11 UTC
    I suggest you get zip. This is a program that runs in a shell, and produces the standard format zip-files. Than do something like (I'm not familiar with win32 perl):
    system("path\zip","zipfile","filenames_that_youwanna_zip");
    This simply creates the zip archive, free at your convenience.

    Hope this helps,

    Jeroen

    I was dreaming of guitarnotes that would irritate an executive kind of guy (FZ)

Re: Creating Zip files
by AgentM (Curate) on Nov 17, 2000 at 22:15 UTC
Re: Creating Zip files
by zzspectrez (Hermit) on Nov 18, 2000 at 02:02 UTC

    This question got me thinking how to do it in windows. Im not sure what platform you are using, but here is how I got it working on Win2000. I use the popular WinZip program to create the files. I first tried using something like system($cmd,"args") but could not get it to work.

    Doing some searching, I found the Win32::Process module. This is my first attempt and a quick hack using this module but it is tested and working.

    Winzip expects filenames to be passed with complete paths and quoted to support long file names: "c:\mypath\to\my\Cool Archive.zip"

    #!/usr/bin/perl -w # Using WinZip to zip files up on Windows machine. use strict; use Win32; use Win32::Process; my $cmd = "C:\\Program Files\\WinZip\\winzip32.exe"; my $rootdir = "c:\\Documents and Settings\\bch\\My Documents"; my $filename = '"c:\\Documents and Settings\\bch\\My Documents\\te +starchive.zip"'; my @files = ('got milk.jpg','kellogs.jpg','gravity.jpg','Resume.do +c'); for my $x (0..(@files-1)) { $files[$x] = qq["$rootdir\\$files[$x]"]; } sub print_error() { return Win32::FormatMessage( Win32::GetLastError() ); } Win32::Process::Create(my $processobj, "$cmd", "winzip32 -min -a $filename @files", 0, DETACHED_PROCESS, ".") or print_error();

    Help this helps!
    zzspectrez