#!/usr/bin/perl use strict; use warnings; use IO::Uncompress::Gunzip; use File::Type; my $ft = File::Type->new(); my @lines_found; for my $file (glob('/home/httpd/thttpd.log*')) { next unless(-f $file); my $fh=undef; if($ft->mime_type($file)=~/gzip/) { unless($fh=IO::Uncompress::Gunzip->new($file)) { warn "ERROR open compressed $file ($IO::Uncompress::Gunzip::GunzipError)"; } } else { unless(open($fh, '<', $file)) { warn "ERROR open $file ($!)\n"; } } if($fh) { while(my $line=<$fh>) { push(@lines_found,$line) if($line=~m!"(?:POST |GET .*=(?:htt|ft|ph)p(?::|%3a)(?:/|%2f)).* HTTP/[0-9]\.[0-9]" [23][0-9]{2}!i) } close($fh); } } print $_ for(@lines_found);