in reply to compressed logfile grep

I have some suggestions, for readability and simplicity.
With utility scripts like this, I find putting the usage at the top of the code, reminds me what this is SUPPOSED to do. &usage is cool , but you can do similarly and IMHO easier as....
my $usage=<<EOF; usage: These are your options punk. EOF die $usage unless ($#ARGV==3);
Also , pretty sure you could use map to replace the core searcher.
print OUTFILE map { /$phrase/ && $_} <INFILE>;
Which might reduce the number of operations you need for each match, rather than a while - if arrangement.

Replies are listed 'Best First'.
Re^2: compressed logfile grep
by Aristotle (Chancellor) on Nov 27, 2002 at 11:45 UTC
    An even simpler way here would be print OUTFILE grep /$phrase/, <INFILE>; Unfortunately replacing while with a map or grep results in slurping the file to search it, which is most likely undesired with logfiles. It can be whittled down though: /$phrase/ && print OUTFILE $_ while <INFILE>;

    Makeshifts last the longest.