heigold1 has asked for the wisdom of the Perl Monks concerning the following question:

I can't find an ActiveState script to zip up files, anywhere.

Does anyone know where I can find one?

A location or pasted script would be greatly appreciated.

Brent.

Replies are listed 'Best First'.
Re: Zip script.
by Joost (Canon) on Jun 20, 2007 at 20:15 UTC
Re: Zip script.
by archfool (Monk) on Jun 20, 2007 at 20:17 UTC
    This script was fat-fingered in (i.e. untested), but here's the process. Archive::Zip comes with ActiveState Perl.
    #!/opt/ActivePerl-5.8/bin/perl use strict; use warnings; use Archive::Zip qw( :ERROR_CODES :CONSTANTS ); my $zip = Archive::Zip->new(); my @files = glob("*.txt"); foreach (@files) { my $member = $zip->addFile($_); die "Cannot add $_ to zip!" unless $member; } die 'write error' unless $zip->writeToFileNamed( 'zipfile.zip' ) == AZ +_OK;
    ActivePerl has HTML documentation on all the modules included. In Windows, you have Start->Programs->ActivePerl ...->Documentation
Re: Zip script.
by FunkyMonk (Bishop) on Jun 20, 2007 at 20:16 UTC
Re: Zip script.
by sago (Scribe) on Jun 21, 2007 at 06:00 UTC


    I used the below script to zip a file and it worked fine.


    use Archive::Zip;
    opendir(PREV,"C:/Documents and Settings/Sam_Gov/Desktop/test_file/");
    while ($file = readdir(PREV)) {
    if ($file = test_file1.txt)
    {
    $addfile = "C:/Documents and Settings/Sam_Gov/Desktop/test_file/" . $file;
    $zipfile = "C:/Documents and Settings/Sam_Gov/Desktop/test_file/" . $file . ".zip";
    $zip = Archive::Zip->new();
    $zip->addFile( $addfile );
    $zip->writeToFileNamed( $zipfile );
    }
    }
    closedir(PREV);