File Coverage

examples/io/gzip/gzgrep
Criterion Covered Total %
statement 18 18 100.0
branch 6 10 60.0
condition n/a
subroutine 3 3 100.0
pod n/a
total 27 31 87.1


line stmt bran cond sub pod time code
1             #!/usr/bin/perl
2              
3 1     1   3416 use strict ;
  1         1  
  1         29  
4 1     1   3 use warnings ;
  1         1  
  1         34  
5 1     1   481 use IO::Uncompress::Gunzip qw($GunzipError);
  1         2  
  1         1283  
6              
7 1 50       118490 die "Usage: gzgrep pattern [file...]\n"
8             unless @ARGV >= 1;
9              
10 1         2 my $pattern = shift ;
11 1         1 my $file ;
12              
13 1 50       3 @ARGV = '-' unless @ARGV ;
14              
15 1         2 foreach $file (@ARGV) {
16 2 50       56 my $gz = new IO::Uncompress::Gunzip $file
17             or die "Cannot uncompress $file: $GunzipError\n" ;
18              
19 2         9 while (<$gz>) {
20 15 100       59 print if /$pattern/ ;
21             }
22              
23 2 50       9 die "Error reading from $file: $GunzipError\n"
24             if $GunzipError ;
25             }
26              
27             __END__