Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: dynamic zcat and grep

by johngg (Abbot)
on Mar 21, 2006 at 23:32 UTC ( #538345=note: print w/ replies, xml ) Need Help??


in reply to dynamic zcat and grep

You could try installing the Compress::Zlib module and use that to read the log file directly.

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->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->close();

I have not tested this but I have adapted it from a script doing somthing similar.

Cheers,

JohnGG


Comment on Re: dynamic zcat and grep
Download Code
Re^2: dynamic zcat and grep
by clmcshque (Initiate) on Mar 22, 2006 at 00:40 UTC
    Ah yes, without the ability to install the module, I cannot try this, I will however test it on another machine. Thank you for the input.
Re^2: dynamic zcat and grep
by clmcshque (Initiate) on Mar 23, 2006 at 17:26 UTC
    Thanks, I got the module installed, and with a bit of tweaking it all works fine now.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://538345]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (7)
As of 2014-09-01 19:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (17 votes), past polls