Perl Requires Chilkat v11.0.0+
Perl
Unzip Text File to String
See more Zip Examples
Demonstrates how to open a .zip and extract the 1st file (assuming it's a text file) to a string variable.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 $zip = Chilkat2::Zip->new;
my $success = $zip->OpenZip('qa_data/zips/EC16100.zip');
if (!$success) {
print $zip->LastErrorText, "\n";
exit;
}
# Get the 1st file in the .zip
my $entry = Chilkat2::ZipEntry->new;
$success = $zip->EntryAt(0, $entry);
if (!$success) {
print $zip->LastErrorText, "\n";
exit;
}
my $fileContents = $entry->UnzipToString(0, 'utf-8');
print $fileContents, "\n";