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

I want to use Archive::Zip to take what would ordinarily go into a file one incremental line at a time and create the contents of a zip format file stored in a string, _without_ ever using the filesystem. You know, something along the lines of:
my $archive = Archive::Zip->new(); my $member = $archive->addDirectory('.'); while ($r = $q->fetchrow_hashref) { my $line = join("\t", map { $r->{$_} } @download_fields); $member->addToString('names.tab', $line); } $self->{state}{download_contents} = "$archive";
Archive::Zip seems hopelessly file-oriented to me. Archive::Zip::MockFileHandle seeme to offer some hope, but no docs, and it's not clear if I can add to the archive incrememntally.
  • Comment on some arbitrary string Archive::Zip contents of zip archive in a string
  • Download Code

Replies are listed 'Best First'.
Re: some arbitrary string Archive::Zip contents of zip archive in a string
by shotgunefx (Parson) on Jan 24, 2002 at 14:37 UTC
    I don't know if it will work in this situation, but you might want to look at IO::Scalar or possible your own Tied Filehandle implementation.

    -Lee

    "To be civilized is to deny one's nature."