use strict; use Compress::Zlib; my $file = $ARGV[0]; if (! $file) { print "$0 \n"; exit; } my $gzfile = $file.".gz"; open (FILE, $file); binmode FILE; my $buf; my $gz = gzopen($gzfile, "wb"); if (! $gz) { print "Unable to write $gzfile $!\n"; exit; } else { while (my $by = sysread (FILE, $buf, 4096)) { if (! $gz->gzwrite($buf)) { print "Zlib error writing to $gzfile: $gz->gzerror\n"; exit; } } $gz->gzclose(); print "'$file' GZipped to '$gzfile'\n"; }