I come as a self-proclaimed n00b seeking wisdom concerning output threading. I've written a very basic routine to retrieve a list of files and push them to a web user via archive::zip. In the code below (please ignore some of the obvious newbie techniques) you'll see that the zip file is being written directly to STDOUT. (This keeps me from having large .zip files lying around that would have to be cleaned up later.) I'd like to go to the next step and give the user the ability to use download accelerators, but given the way the .zip file is being created, I'm not sure if it is even possible to open multiple output threads. Am I wrong? Any little push in the right direction would be greatly appreciated.
#!/usr/bin/perl -w use CGI ':standard'; use String::CRC32; use Archive::Zip qw(:ERROR_CODES :CONSTANTS); $myname = $0; $myname =~ s/\///g; $myname =~ s/usrlocalweb//; $myname =~ s/.cgi//; $zip = Archive::Zip->new(); print "Content-disposition: filename=$myname.zip\n"; print "Content-type: Application/zip\n\n"; open (LISTIT, "<$myname.txt"); while (<LISTIT>) { $_ =~ s/\n//g; push @filenames,$_; } $filecount = ($#filenames)+1; close (LISTIT); for ($loop=0; $loop < $filecount; $loop++) { my $member = $zip->addFile( $filenames[$loop] ); $member->desiredCompressionMethod( COMPRESSION_DEFLATED ); $member->desiredCompressionLevel( 9 ); } $output = $zip->writeToFileHandle( STDOUT ); exit $output;
Thanks, -BKoT-

In reply to Threading http file transfers by BKoT

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.