use IO::Compress::Gzip qw(gzip $GzipError); my $gzip_data; my $status = gzip $input => \$gzip_data [,OPTS] or die "gzip failed: $GzipError\n";