File Coverage

examples/compress-zlib/gzgrep
Criterion Covered Total %
statement 18 18 100.0
branch 5 8 62.5
condition n/a
subroutine 3 3 100.0
pod n/a
total 26 29 89.6


line stmt bran cond sub pod time code
1             #!/usr/local/bin/perl
2              
3 1     1   9617 use strict ;
  1         2  
  1         45  
4 1     1   6 use warnings ;
  1         2  
  1         90  
5              
6 1     1   783 use Compress::Zlib ;
  1         4  
  1         2162  
7              
8 1 50       245948 die "Usage: gzgrep pattern file...\n"
9             unless @ARGV >= 2;
10              
11 1         4 my $pattern = shift ;
12              
13 1         3 my $file ;
14              
15 1         3 foreach $file (@ARGV) {
16 2 50       67 my $gz = gzopen($file, "rb")
17             or die "Cannot open $file: $gzerrno\n" ;
18              
19 2         10 while ($gz->gzreadline($_) > 0) {
20 15 100       169 print if /$pattern/ ;
21             }
22              
23 2 50       8 die "Error reading from $file: $gzerrno\n"
24             if $gzerrno != Z_STREAM_END ;
25              
26 2         14 $gz->gzclose() ;
27             }