sanvin has asked for the wisdom of the Perl Monks concerning the following question:
I have tried zipping a directory which contains sub directories and files and this is my code.
!/usr/bin/perl -w use strict; use List::Util qw(first); use Archive::Zip qw(:ERROR_CODES :CONSTANTS); my $input= 'D:\temp\sample'; my $outDir = 'D:\out\sample.zip'; my $obj = Archive::Zip->new(); $obj->addTree( $input ); # # Write the files to zip. if ($obj->writeToFileNamed($outDir) == AZ_OK) { # write to disk print "\n\nArchive created successfully!\n"; } else { print "Error while Zipping !"; }
When i execute this, the zip file ( sample.zip ) is created.
Always the unzipping is done manually selecting the option " Extract Here ".
When i unzip this , the directory bursts open putting all the subfolders and files at the same location( D:\out).
What i want is, i expect the output to be a unique folder ( D:\out\sample) So, what changes need to be done in my code. Pls help me.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to zip the directory in a required format
by Athanasius (Archbishop) on Oct 28, 2015 at 06:28 UTC | |
by sanvin (Novice) on Oct 28, 2015 at 09:48 UTC | |
|
Re: How to zip the directory in a required format
by Corion (Patriarch) on Oct 28, 2015 at 09:50 UTC |