Does anyone know how to get wzzip to work in a cgi script?

I have written a script that creates an excel file and then zips it up using wzzip.exe. I have found that I cannot return both the HTML page to the user and create a zip file and generate an email (using MIME) with the attached zip file.

If I first return the html page it works, as does the generation of the zip file ... but the email does not arrive. If I first create the zip file and the email it returns the email with the zip file but I get the CGI Error "The specified CGI application misbehaved by not returning a complete set of HTTP headers." If I comment out the command line calls (either of them as shown below) I can do both things and attach a previously generated zip file. I want to use wzzip as most users will have winzip and when I generated zip files using the archive zip module I could not use winzip to open them. Running Wzzip I have used the following code:
1. my $zippath = qq(\"C:\\Program Files\\WinZip\\wzzip.exe\" \-a \"$zi +p_file\" \"$filetoZip\"); my $status = system ($zippath);
2. my $winzip= qq(\"c:\\program files\\winzip\\wzzip.exe"); open OUT, "| $winzip $zip_options $zip_file $filetoZip" or die "wzzip pipe: $!"; print OUT "\n"; close OUT;
I think it may have something to do with winzip changing the stdout or stderr ... but not sure how to stop this. I would really appreciate a perl monk to help me. Thankyou, Hshepherd

In reply to CGI Wzzip and MIME by hshepherd

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.