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