Question

im using perl module to extract a .zip file and it consist of many sub directories and im using the below code

my $extract_path = $des_path . "\\files";
mkdir $extract_path;
my $filename = $des_path . "\\" . basename($zipfile_path);
my $zip = Archive::Zip->new($filename);

foreach my $member ($zip->members)
{
    next if $member->isDirectory;
    (my $extractName = $member->fileName) =~ s{.*/}{};
    $member->extractToFileNamed("$extract_path/$extractName");
}

but my problem is it is place the entire file in a single folder and avoiding the sub folders .That is entire files are placed in a single folder instead of making subfolders

what went wrong any one help me

thanks

Était-ce utile?

La solution

Try replacing your foreach block with

$zip->extractTree();

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top