Welcome to WebmasterWorld Guest from 54.196.208.6

Forum Moderators: coopster & jatar k & phranque

Message Too Old, No Replies

How to inflate a GZIP in perl

At my provider no mod_gunzip available

     
8:27 pm on Mar 30, 2009 (gmt 0)

Senior Member

WebmasterWorld Senior Member jetteroheller is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Jan 22, 2005
posts: 2979
votes: 1


Since at my content provider, mod_gunzip is not available,
I have to simulate the most important part myself.

use Compress::Zlib;

my $buffer = sub_to_laod_a_file ( "gzip compressed file" );

my $out = uncompress ( $buffer );

$buffer contains the compressed file,
but $out has 0 byte length.

What's wrong?

4:12 am on Mar 31, 2009 (gmt 0)

Administrator

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Aug 10, 2004
posts:10542
votes: 8


if $out contains no content it is undefined which means an error occurred:
COMPRESS/UNCOMPRESS [search.cpan.org]

these methods are intended for ZLIB Compressed Data Format Specification [ietf.org] (RFC-1950) and you probably want something that works for GZIP file format specification [ietf.org] (RFC-1952).

GZIP INTERFACE [search.cpan.org]:
Compress::Zlib::memGunzip [search.cpan.org]

try using this instead;

$out = Compress::Zlib::memGunzip($buffer) ;
6:30 am on Mar 31, 2009 (gmt 0)

Senior Member

WebmasterWorld Senior Member jetteroheller is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Jan 22, 2005
posts: 2979
votes: 1


Thanks! That works!