#!perl use strict; my $DATE= do { my($y,$m,$d)= (localtime(time-60*60*(12+(localtime)[2]) ))[5,4,3]; sprintf "%04d-%02d-%02d", 1900+$y, 1+$m, $d; }; open INPUT,"<","SyslogCatchAll.txt"||die "Can not open input file: $!\n"; open CSV,">","$DATE.csv"||die "Can not open $DATE.csv: $!\n"; print CSV "Date,Time,WS 2000,FW Date,FW Time,Store,Src IP,Src Port,Dst IP,Dst Port,Type,Agent,Message\n"; while(){ $_=~m/msg=(.*) Src/; my $msg = $1; my @line = split /\s+/; my $Date = $line[0]; next if ($Date ne $DATE); my $Time = $line[1]; my $ws2k = $line[3]; my $FWD = $line[5]; my $FWT = $line[6]; my $store = $line[8]; my $src_ip = $line[11]; my $dst_ip = $line[12]; my $src_prt = $line[$#line - 6]; my $dst_prt = $line[$#line - 4]; my $type = $line[$#line - 2]; my $agent = $line[$#line]; chomp $agent; $agent=~s/agent=//; $FWD=~s/time="//; $FWT=~s/"//; $src_ip=~s/src=//; $dst_ip=~s/dst=//; $msg=~s/,/ /; print CSV "$Date,$Time,$ws2k,$FWD,$FWT,$store,$src_ip,$src_prt,$dst_ip,$dst_prt,$type,$agent,$msg\n"; } close INPUT; close CSV;