Это то, что вам нужно?Вы распаковываете данные, устанавливаете заголовок Content-encoding и отправляете его.
use strict;
use warnings;
use HTTP::Response;
use IO::Compress::Gzip qw(gzip);
my $data = q(My cat's name is Buster);
my $gzipped_data;
my $gzip = gzip \$data => \$gzipped_data;
print STDERR $gzipped_data;
my $response = HTTP::Response->new;
$response->code( 200 );
$response->header( 'Content-type' => 'text/plain' );
$response->header( 'Content-encoding' => 'gzip' );
$response->header( 'Content-length' => length $gzipped_data );
$response->content( $gzipped_data );
print $response->as_string;