I wanted the same for a Perl CGI script so I dug a bit on the Net and here's the code I came up with:<?php ob_start("ob_gzhandler"); ?>
Mind you I am not using CGI.pm as it's a memory hog and in this particular script I did not have to parse form variables.use strict;
use Compress::Zlib qw(gzopen);
print <<EOF;
Content-Type: text/html
Content-Encoding: gzip
EOF
my $print;
binmode STDOUT;
{ # closure
my $gz = gzopen(\*STDOUT, "wb");
$print = sub { $gz->gzwrite(@_) };
}
$print->("Some content....");
On another note importing just what you need from a Perl module [i.e. qw(gzopen)] is a great way to cut down on memory consumption.
-ulianov