[Wellington-pm] decompressing a string

Dan Horne dan.horne at redbone.co.nz
Wed Nov 14 12:53:14 PST 2012

Hi Mongers

I'm trying to convert a Python routine to Perl. The point where I'm stuck
is where I need to decompress a string. The Python code is something like
(extraneous code removed)

import zlib
mystring = '<value from previous function>'
print zlib.decompress(mystring)

However, it's not clear to me how to replicate this in Perl. I've tried

use Compress::Zlib;
my $mystring = '<value from previous function>';
my $x = deflateInit();
my ($out,$status) = $x->deflate($mystring );
$status == Z_OK or die "deflation failed\n";
print $out;

Unfortunately, the Perl code doesn't work - $out is gobbledygook -- and as
far as I can tell from the doco, Compress::Zlib seems to be interested in
decompressing filehandles not strings. Any advice on how to decompress a
string appreciated

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/wellington-pm/attachments/20121115/0eaee88c/attachment.html>

More information about the Wellington-pm mailing list