| 1 | #!/usr/bin/perl | ||||||||||
| 2 | |||||||||||
| 3 | 1 | ▶ | use strict ; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | ▶ | use warnings ; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 1 | ▶ | use IO::Uncompress::Bunzip2 qw($Bunzip2Error); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 1 | ▶ | die "Usage: gzgrep pattern [file...]\n" | ||||||||
|
Branch: 1 branch
| |||||||||||
| 8 | unless @ARGV >= 1; | ||||||||||
| 9 | |||||||||||
| 10 | 1 | my $pattern = shift ; | |||||||||
| 11 | 1 | my $file ; | |||||||||
| 12 | |||||||||||
| 13 | 1 | ▶ | @ARGV = '-' unless @ARGV ; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 14 | |||||||||||
| 15 | 1 | foreach $file (@ARGV) { | |||||||||
| 16 | 2 | ▶ | my $gz = new IO::Uncompress::Bunzip2 $file | ||||||||
|
Branch: 1 branch
| |||||||||||
| 17 | or die "Cannot uncompress $file: $Bunzip2Error\n" ; | ||||||||||
| 18 | |||||||||||
| 19 | 2 | ▶ | while (<$gz>) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 20 | 15 | ▶ | print if /$pattern/ ; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 21 | } | ||||||||||
| 22 | |||||||||||
| 23 | 2 | ▶ | die "Error reading from $file: $Bunzip2Error\n" | ||||||||
|
Branch: 1 branch
| |||||||||||
| 24 | if $Bunzip2Error ; | ||||||||||
| 25 | } | ||||||||||