summaryrefslogtreecommitdiff
path: root/ext/IO-Compress/examples/io/gzip/gzcat
diff options
context:
space:
mode:
Diffstat (limited to 'ext/IO-Compress/examples/io/gzip/gzcat')
-rwxr-xr-xext/IO-Compress/examples/io/gzip/gzcat29
1 files changed, 29 insertions, 0 deletions
diff --git a/ext/IO-Compress/examples/io/gzip/gzcat b/ext/IO-Compress/examples/io/gzip/gzcat
new file mode 100755
index 0000000000..5572bae959
--- /dev/null
+++ b/ext/IO-Compress/examples/io/gzip/gzcat
@@ -0,0 +1,29 @@
+#!/usr/local/bin/perl
+
+use IO::Uncompress::Gunzip qw( $GunzipError );
+use strict ;
+use warnings ;
+
+#die "Usage: gzcat file...\n"
+# unless @ARGV ;
+
+my $file ;
+my $buffer ;
+my $s;
+
+@ARGV = '-' unless @ARGV ;
+
+foreach $file (@ARGV) {
+
+ my $gz = new IO::Uncompress::Gunzip $file
+ or die "Cannot open $file: $GunzipError\n" ;
+
+ print $buffer
+ while ($s = $gz->read($buffer)) > 0 ;
+
+ die "Error reading from $file: $GunzipError\n"
+ if $s < 0 ;
+
+ $gz->close() ;
+}
+