in reply to Creating files within a .zip

This works with perl5 (revision 5 version 16 subversion 1):

#!/opt/perl/bin/perl use warnings; use strict; use diagnostics; use Archive::Zip qw( :ERROR_CODES :CONSTANTS ); MAIN: { my $zd = 'foobar'; my $zip = Archive::Zip->new(); my $d = $zip->addDirectory( $zd ); my $f = $zip->addString( 'this is a test', "$zd/foo.txt" ); $f->desiredCompressionMethod( COMPRESSION_DEFLATED ); $f = $zip->addString( 'of the emergency broadcast system', "$zd/ba +r.txt" ); $f->desiredCompressionMethod( COMPRESSION_DEFLATED ); unless ( $zip->writeToFileNamed("$zd.zip") == AZ_OK ) { die 'write error'; } exit 0; }
$ unzip -l foobar.zip
Archive:  foobar.zip
  Length     Date   Time    Name
 --------    ----   ----    ----
        0  09-28-12 11:18   foobar/
       14  09-28-12 11:18   foobar/foo.txt
       33  09-28-12 11:18   foobar/bar.txt
 --------                   -------
       47                   3 files
$

Replies are listed 'Best First'.
Re^2: Creating files within a .zip
by wumpus42 (Novice) on Sep 28, 2012 at 16:27 UTC

    In the above example/solution the foobar/ directory never existed in the filesystesm. It only exists in the .zip file.

      Has Archive::Zip given you what you want then?