summaryrefslogtreecommitdiff
path: root/cpan/IO-Compress/examples/compress-zlib/gzcat
blob: 5241a5a11fb11bf37905f0d7fe85791c10e74975 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/local/bin/perl

use strict ;
use warnings ;

use Compress::Zlib ;

#die "Usage: gzcat file...\n"
#    unless @ARGV ;

my $filename ;

@ARGV = '-' unless @ARGV ;

foreach my $filename (@ARGV) {
    my $buffer ;

    my $gz = gzopen($filename, "rb") 
         or die "Cannot open $filename: $gzerrno\n" ;

    print $buffer while $gz->gzread($buffer) > 0 ;

    die "Error reading from $filename: $gzerrno" . ($gzerrno+0) . "\n" 
        if $gzerrno != Z_STREAM_END ;
    
    $gz->gzclose() ;
}