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

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");

Replies are listed 'Best First'.
Re^3: Unzipping and extracting file only with Archive::Zip
by Mr. Muskrat (Canon) on Nov 28, 2017 at 19:46 UTC
    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");