Reputation: 175
Is it possible to create a ZIP archive using IO::Compress::Zip without retaining the full paths of the incoming files?
For example - if I add /tmp/foo/file.pdf to a zip file, I want the /tmp/foo path dropped when it is added to the archive. Is this possible? Is there another module that can do this?
Upvotes: 0
Views: 1011
Reputation: 11694
See the FilterName
option in the documentation for IO::Compress::Zip
Although this option can be used with the OO ointerface, it is of most use with the one-shot interface. For example, the code below shows how FilterName can be used to remove the path component from a series of filenames before they are stored in $zipfile.
sub compressTxtFiles { my $zipfile = shift ; my $dir = shift ; zip [ <$dir/*.txt> ] => $zipfile, FilterName => sub { s[^$dir/][] } ; }
Upvotes: 4