#!perl use strict; open INPUT,"<","input_file.txt"||die "Can not open input_file: $!\n"; open CSV,">","OUTPUT.csv"||die "Can not open OUTPUT.csv: $!\n"; print CSV "Date,Time,WS 2000,FW Date,FW Time,Store,Src IP,Src Port,Dst IP,Dst Port,Type,Agent\n"; while(){ my @line = split /\s+/; my $Date = $line[0]; my $Time = $line[1]; my $ws2k = $line[3]; my $FW_Date = $line[5]; my $FW_Time = $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=//; $FW_Date=~s/time="//; $FW_Time=~s/"//; $src_ip=~s/src=//; $dst_ip=~s/dst=//; print CSV "$Date,$Time,$ws2k,$FW_Date,$FW_Time,$store,$src_ip,$src_prt,$dst_ip,$dst_prt,$type,$agent\n"; } close INPUT; close CSV;