| 1 | #!/usr/local/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 | |||||||||||
| 6 | 1 | ▶ | use Compress::Zlib ; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 1 | ▶ | die "Usage: gzgrep pattern file...\n" | ||||||||
|
Branch: 1 branch
| |||||||||||
| 9 | unless @ARGV >= 2; | ||||||||||
| 10 | |||||||||||
| 11 | 1 | my $pattern = shift ; | |||||||||
| 12 | |||||||||||
| 13 | 1 | my $file ; | |||||||||
| 14 | |||||||||||
| 15 | 1 | foreach $file (@ARGV) { | |||||||||
| 16 | 2 | ▶ | my $gz = gzopen($file, "rb") | ||||||||
|
Branch: 1 branch
| |||||||||||
| 17 | or die "Cannot open $file: $gzerrno\n" ; | ||||||||||
| 18 | |||||||||||
| 19 | 2 | ▶ | while ($gz->gzreadline($_) > 0) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 20 | 15 | ▶ | print if /$pattern/ ; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 21 | } | ||||||||||
| 22 | |||||||||||
| 23 | 2 | ▶ | die "Error reading from $file: $gzerrno\n" | ||||||||
|
Branch: 1 branch
| |||||||||||
| 24 | if $gzerrno != Z_STREAM_END ; | ||||||||||
| 25 | |||||||||||
| 26 | 2 | $gz->gzclose() ; | |||||||||
| 27 | } | ||||||||||