in reply to examples using Compress::Zlib ?

Apache::GzipChain (on CPAN) uses Compress::Zlib. You could look at its source.

Did you see the examples in the Compress::Zlib docs? They have some examples of using gzopen, gzwrite, gzread, etc.