• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 693
  • Last Modified:

Perl and zgrep

I have a small script that will search log files, the files go back several months, all the files that are over a week old are compressed so I use zgrep when seaching the ones older than a week. I have a small perl script that I use to search the files but cannot make it work on the files older than a week. Is there a way i can use zgrep in the script to search the zipped files.

Thanks,
0
bt707
Asked:
bt707
1 Solution
 
jmcgOwnerCommented:
Your script can call on zgrep or zcat to read the files or it can use the Compress::Zlib module to do the decompression itself.

open LOGF, "zcat $filename |" or die "failed starting zdat on $filename -- $!";

while( <LOGF> ) {
   # do your thing here -- use zgrep instead of zcat if the grep action does what you need
  }

0
 
bt707Author Commented:
Thanks for the info, i think i can get it going with that.

Thanks,
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now