diff options
Diffstat (limited to 'cpan/IO-Compress/examples/io/bzip2/bzcat')
-rwxr-xr-x | cpan/IO-Compress/examples/io/bzip2/bzcat | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/cpan/IO-Compress/examples/io/bzip2/bzcat b/cpan/IO-Compress/examples/io/bzip2/bzcat new file mode 100755 index 0000000000..81123200c5 --- /dev/null +++ b/cpan/IO-Compress/examples/io/bzip2/bzcat @@ -0,0 +1,29 @@ +#!/usr/local/bin/perl + +use IO::Uncompress::Bunzip2 qw( $Bunzip2Error ); +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::Bunzip2 $file + or die "Cannot open $file: $Bunzip2Error\n" ; + + print $buffer + while ($s = $gz->read($buffer)) > 0 ; + + die "Error reading from $file: $Bunzip2Error\n" + if $s < 0 ; + + $gz->close() ; +} + |