Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Unzipping and extracting file only with Archive::Zip

by Mr. Muskrat (Canon)
on Nov 28, 2017 at 19:18 UTC ( #1204465=note: print w/replies, xml ) Need Help??


in reply to Unzipping and extracting file only with Archive::Zip

The code you posted should extract all members from the archive. Can you show us the code where you attempted to extract only houses.txt so that we can help you fix it?

  • Comment on Re: Unzipping and extracting file only with Archive::Zip

Replies are listed 'Best First'.
Re^2: Unzipping and extracting file only with Archive::Zip
by Anonymous Monk on Nov 28, 2017 at 19:25 UTC
    I tried using this from the module thinking that it would remove the path where the file is and extract the file only, but no luck.
    $zip->extractMemberWithoutPaths($member, "/zips/$member");
      use strict; use warnings; use Archive::Zip qw( :ERROR_CODES :CONSTANTS ); use Data::Dumper; my $zipFile = "myzip.zip"; my $archiveDir = '/fileDirectory'; my $zip = Archive::Zip->new(); my $status = $zip->read("$archiveDir/$zipFile"); die "Read of $zip failed\n" if $status != AZ_OK; $zip->extractMemberWithoutPaths('info/home/houses.txt', '/zips/houses. +txt'); #$zip->extractMember('info/home/houses.txt', '/zips/houses.txt'); # ei +ther works for me
        Its one of those days where you cant see anything. The issues is right here:
        $zip->extractMember($member, "/zips/$member");
        I was naming the file with "$member". When it should be like this:
        $zip->extractMember($member, "/zips/file_name");

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1204465]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (7)
As of 2022-05-20 08:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (73 votes). Check out past polls.

    Notices?