[Wellington-pm] decompressing a string
Grant McLean
grant at mclean.net.nz
Wed Nov 14 13:15:16 PST 2012
On Thu, 2012-11-15 at 09:53 +1300, Dan Horne wrote:
> 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)
I fought with something similar to this a while ago. The key detail that
I was missing is the difference between gzip and inflate/deflate. My
understanding is that they are both implemented in zlib but gzipping
adds some envelope around the raw deflated data.
I ended up using the IO::Uncompress::RawInflate module because I found a
code example that worked in my situation (I was dealing with an XML
document that had been compressed and then base64 encoded and then URL
encoded). Despite the 'IO::' prefix, this module does work with
in-memory strings. The relevant snippet is here:
https://metacpan.org/source/GRANTM/Authen-NZigovt-1.05/lib/Authen/NZigovt/AuthenRequest.pm#L202
Hope that helps
Grant
More information about the Wellington-pm
mailing list