<?xml version="1.0" encoding="windows-1252"?>
<node id="538345" title="Re: dynamic zcat and grep" created="2006-03-21 18:32:19" updated="2006-03-21 13:32:19">
<type id="11">
note</type>
<author id="401112">
johngg</author>
<data>
<field name="doctext">
You could try installing the Compress::Zlib module and use that to read the log file directly.&lt;p&gt;
&lt;code&gt;
use strict;
use warnings;

use Compress::Zlib;

# Set up what we want to match.
#
our $reg1 = "Joe Sinclair";
our $reg2 = "Bill Halburg";
our $rxNames = qr{(?:$reg1|$reg2)}

# Open compressed log file.
#
our $logFile = "file.gz";
our $gzInput = gzopen($logFile, "rb")
   or die "gzopen: $gzerrno\n";

# Read line by line into $_ counting bytes read.
#
our $bytesRead;
while($bytesRead = $gzInput-&gt;gzreadline($_))
{
    # Print if it matches.
    #
    print if /$rxNames/;
}

# Check that we have read to the end. Close
# file.
#
die "Incomplete read: $gzerrno\n" unless
   $gzerrno == Z_STREAM_END;
$gzInput-&gt;close();
&lt;/code&gt;&lt;p&gt;
I have not tested this but I have adapted it from a script doing somthing similar.&lt;p&gt;Cheers,&lt;p&gt;JohnGG</field>
<field name="root_node">
538316</field>
<field name="parent_node">
538316</field>
</data>
</node>
