No need to chdir. The FilterName option was written primarily to handle this use case. The code below assumes Unix/Linux path delimeters.
zip [$tmpfiles.'/file1.txt',$tmpfiles.'file2.txt'] =>$tmpfiles.'/output.zip', FilterName => sub { s[^.*/][] };
Alternatively, you could do away with the temporary files completely and write directly to the zip file
use Archive::Zip::SimpleZip qw($SimpleZipError) ; my $z = new Archive::Zip::SimpleZip $tmpfiles.'/output.zip' or die "Cannot create zip file: $SimpleZipError\n" ; # If the data is in a string $z->addString("some text", Name => "file1.txt"); # or if you need carry out more complex processing $fh = $z->openMember(Name => "file3.txt"); print $fh "some data" ; print $fh "some more data" ; close $fh; $z->close();
In reply to Re: Zip only files, not directory hierarchy.
by pmqs
in thread Zip only files, not directory hierarchy.
by desertrat
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |