Perl
Chilkat2 Perl
bz2 Compress File
Compress a file to the bz2 file format.Chilkat Perl Downloads
use strict;
use warnings;
use Chilkat2;
# This example requires the Chilkat API to have been previously unlocked.
# See Global Unlock Sample for sample code.
my $bz2 = Chilkat2::Bz2->new;
# Compress the file qa_data/hamlet.xml to create qa_output/hamlet.bz2
my $success = $bz2->CompressFile('qa_data/hamlet.xml', 'qa_output/hamlet.bz2');
if (!$success) {
print $bz2->LastErrorText, "\n";
exit;
}
print "Success.\n";