File Coverage

examples/io/bzip2/bzgrep
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   4911 use strict ;
  1         1  
  1         35  
4 1     1   3 use warnings ;
  1         2  
  1         53  
5 1     1   557 use IO::Uncompress::Bunzip2 qw($Bunzip2Error);
  1         3  
  1         1618  
6              
7 1 50       185992 die "Usage: gzgrep pattern [file...]\n"
8             unless @ARGV >= 1;
9              
10 1         4 my $pattern = shift ;
11 1         2 my $file ;
12              
13 1 50       5 @ARGV = '-' unless @ARGV ;
14              
15 1         3 foreach $file (@ARGV) {
16 2 50       112 my $gz = new IO::Uncompress::Bunzip2 $file
17             or die "Cannot uncompress $file: $Bunzip2Error\n" ;
18              
19 2         14 while (<$gz>) {
20 15 100       158 print if /$pattern/ ;
21             }
22              
23 2 50       13 die "Error reading from $file: $Bunzip2Error\n"
24             if $Bunzip2Error ;
25             }