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