#!/usr/local/bin/perl
$in = 'stripaccess.log';
$out ='/illustra/pruned.log';
$domaincodes = '/illustra/codes/domain.desc';
open (Deep,"<$in");

open (Shit,">$out");
while ($line =<Deep>) {
($remote, $dash1, $dash2, $date, $tz, $method, $page, $protocol, $protnum1, $size)=
split(/\s/,$line);
$date =~ s/\[//;
local($date, $hour, $min, $sec) = split(":", $date);
local($date, $dd, $mmm, $yyyy) = split("/", $date);

$domainExt = $remote;
$domainExt =~ s/.*\.//g; 
$domainExt = "IP" if ($domainExt =~ /[0-9].*/); 
$domainExt =~ tr/[a-z]/[A-Z]/; 

$domain = $domainExt;
#print "The result of this mess is $domain\n";
#$free = "IP Address" if  ($domainExt =~ /[0-9].*/);
#print "I am here with my address being $free\n";
#if ($domain ne "IP") {
open (CODES, "<$domaincodes") || die "Couldn't open $domaincodes\n";  
while ($desc =<CODES>) { 
chop($desc); 
if($desc =~ /(\w+)\s(.*)/) {
$description = $2;
$code = $1;  
}

if ($domain eq $code) {
$free = $description;
}
}

#print "Hopefully this shoud get to read as $description\n";

#print "the domain is $free\n";


$method =~ s/\"//g;
$protnum1 =~ s/\"//g;


print Shit "$remote\t$mmm-$dd-$date $hour:$min:$sec\t$method\t$page\t$protocol\t$protnum1\t$size\t$free\n" || die "I cant
help it Captain";  

}
