Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Re: how to zip files using perl

by dynamo (Chaplain)
on Oct 10, 2007 at 17:54 UTC ( [id://644044] : note . print w/replies, xml ) Need Help??

in reply to how to zip files using perl

If you're on a mac (or unix machine with the 'zip' utility installed), the simplest way to do it is with backticks. I'll assume you just generated file1.html, file2.css, and file2.png. I'm also assuming you'd want to use the name
my @files2zip = qw/file1.html file2.css file3.png/; my $fileStr = join(" ",@files2zip); my $zipfile = ""; my $output = `zip $zipfile $filesStr`; print "Progress:\n$output\n\nYour files are in [$zipfile].";
If you don't have the zip cmdline util handy, consider tar -z, it's not the same but it compresses decently. Failing that, or if you prefer, check out the previous post about the CPAN module.