Reputation: 2625
I have a zip file X and I'd like do extract a single file, located in x/x/x/file.txt. How do I do this using Archive::Zip
and Perl?
Upvotes: 6
Views: 5606
Reputation: 455420
You can use the extractMember
method:
extractMember( $memberOrName [, $extractedName ] )
Extract the given member, or match its name and extract it. Returns undef if member doesn't exist in this Zip. If optional second arg is given, use it as the name of the extracted member. Otherwise, the internal filename of the member is used as the name of the extracted file or directory. If you pass $extractedName, it should be in the local file system's format. All necessary directories will be created. Returns AZ_OK on success.
Upvotes: 10
Reputation: 39158
See Archive::Zip::FAQ, "extract file(s) from a Zip". The current version of the example file is online at http://cpansearch.perl.org/src/ADAMK/Archive-Zip-1.30/examples/extract.pl.
Upvotes: 4