in reply to Recommendation to zip/unzip gzip files

If your data is line-oriented (or otherwise processed in chunks), I'd just open a pipe to an external process:

# read open my $in, '-|', 'gzip', '-dc', $filename; while (<$in>) { print $_; } close $in; # write open my $out, '|-', 'gzip', '-c', $filename; print $out "blah"; close $out;

Replies are listed 'Best First'.
Re^2: Recommendation to zip/unzip gzip files
by Anonymous Monk on Jul 03, 2012 at 11:08 UTC

    Whoops, that writing doesn't quite work (it prints the compressed data to STDOUT), and I'm not sure how to fix that without invoking the shell.

    With the shell, it goes something like this:

    open my $out, '| gzip -c > ' . $filename;