Move if from ext/ to cpan/
[p5sagit/p5-mst-13.2.git] / ext / IO-Compress / examples / io / bzip2 / bzgrep
CommitLineData
319fab50 1#!/usr/bin/perl
2
3use strict ;
dc82791d 4use warnings ;
319fab50 5use IO::Uncompress::Bunzip2 qw($Bunzip2Error);
6
7die "Usage: gzgrep pattern [file...]\n"
8 unless @ARGV >= 1;
9
10my $pattern = shift ;
11my $file ;
12
13@ARGV = '-' unless @ARGV ;
14
15foreach $file (@ARGV) {
16 my $gz = new IO::Uncompress::Bunzip2 $file
17 or die "Cannot uncompress $file: $Bunzip2Error\n" ;
18
19 while (<$gz>) {
20 print if /$pattern/ ;
21 }
22
23 die "Error reading from $file: $Bunzip2Error\n"
24 if $Bunzip2Error ;
25}