Link to home
Start Free TrialLog in
Avatar of lakshmi_n
lakshmi_n

asked on

How to create zip files withou using Archive::zip?

Hi techies,

I have an array of filenames, I want to create a zip file without using Archive::zip module.
Can anybody help me with code?
It is very urgent...

Thanks in advance,
Lakshmi
Avatar of jmcg
jmcg
Flag of United States of America image

If you don't want to use Archive::Zip, does that mean that you also don't want to use Compress::Zlib or the binary Zlib or the binary executable 'zip' program? If we understood better the particular reason you want to do this with one or both hands tied behind your back, we might be able to give you a satisfactory answer.
Avatar of Tintin
Tintin

Assuming you have zip on the system, you can do:

system "zip", "filename.zip", @arrayoffilenames and die "Can not run zip $!\n";
Avatar of lakshmi_n

ASKER

Hi,

I dont want to use any non-standard modules that does not come along with Active Perl

Thanks,
Lakshmi
Using Compress:Zlib, how do I compress the files to .zip?
You don't. Zlib is a different compression algorithm.
I suggest you use Archive::Tar (which comes with ActivePerl), and use the 'compressed' option to make a tar.gz file (which Winzip can open).

Something like this:

use Archive::Tar;

$tar = new Archive::Tar;
$tar->add_files( your files here );
$tar->write( 'yourfile.tar.gz', 1 );
ASKER CERTIFIED SOLUTION
Avatar of Tintin
Tintin

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial