# Grab the incoming file
my $argv = join(' ', @ARGV) or die "Usage: zipme.pl [file location]\n";
# Grab the file name
my($dir, $file) = $argv =~ m/(.*\\)(.*)$/;
# Create a Zip file
use Archive::Zip qw( :ERROR_CODES :CONSTANTS );
my $zip = Archive::Zip->new();
# Add the file
my $file_member = $zip->addFile($argv, $file);
# Save the Zip file
unless ( $zip->writeToFileNamed($argv.'.zip') == AZ_OK ) {
die 'couldn\'t zip';
}
Save this code as zipme.pl, and you'll be set. Pass in a filename, and you'll get a compressed file of the same name plus the .zip extension. So:
C:\>perl zipme.pl C:\path\to\giant.file
will give you
C:\path\to\giant.file.zip. It works well with Windows batch files, and will save me a bunch of bandwidth.