[Wellington-pm] decompressing a string

Olly Betts olly at survex.com
Wed Nov 14 13:05:33 PST 2012


On Thu, Nov 15, 2012 at 09:53:14AM +1300, Dan Horne wrote:
> 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

Don't you just want to use Compress::Zlib::uncompress:

   $dest = uncompress($source) ;
	Uncompresses $source. If successful it returns the uncompressed
	data. Otherwise it returns undef.

	The source buffer can either be a scalar or a scalar reference.

Cheers,
    Olly


More information about the Wellington-pm mailing list