X-Git-Url: https://perl5.git.perl.org/perl5.git/blobdiff_plain/274ac62a3e605d66baf0a73d4dde20b3a2ea7120..25f0751fb55a0f87a7e18ae8960f9acf2407ae32:/ext/Compress/Zlib/examples/gzcat diff --git a/ext/Compress/Zlib/examples/gzcat b/ext/Compress/Zlib/examples/gzcat index 5572bae..3bbd297 100755 --- a/ext/Compress/Zlib/examples/gzcat +++ b/ext/Compress/Zlib/examples/gzcat @@ -1,29 +1,30 @@ #!/usr/local/bin/perl -use IO::Uncompress::Gunzip qw( $GunzipError ); use strict ; use warnings ; +use Compress::Zlib ; + #die "Usage: gzcat file...\n" # unless @ARGV ; -my $file ; -my $buffer ; -my $s; +my $filename ; @ARGV = '-' unless @ARGV ; -foreach $file (@ARGV) { - - my $gz = new IO::Uncompress::Gunzip $file - or die "Cannot open $file: $GunzipError\n" ; +foreach my $filename (@ARGV) { + my $buffer ; + + my $file = $filename ; + $file = \*STDIN if $file eq '-' ; - print $buffer - while ($s = $gz->read($buffer)) > 0 ; + my $gz = gzopen($file, "rb") + or die "Cannot open $file: $gzerrno\n" ; - die "Error reading from $file: $GunzipError\n" - if $s < 0 ; + print $buffer while $gz->gzread($buffer) > 0 ; + + die "Error reading from $filename: $gzerrno" . ($gzerrno+0) . "\n" + if $gzerrno != Z_STREAM_END ; - $gz->close() ; + $gz->gzclose() ; } -