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


In reply to Re: Creating Zip files by zzspectrez
in thread Creating Zip files by Beelzebub

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.