#!/usr/bin/perl -w use strict; use Spreadsheet::WriteExcel::Big; open (IN, "temp.txt") || die "Cannot open temp.txt\n"; # set up Excel spreadsheet my $workbook = Spreadsheet::WriteExcel::Big->new("temp.xls"); my $worksheet = $workbook->addworksheet(); my $inLine; my $row = 0; while ($inLine = ) { my ($date, $log, $protocol, $firstIP, $secondIP, $packets) = split(/,/, $inLine); # strip port number if it exists if ($firstIP =~ /([\d.]+)\((\d+)\)/) { my $ip1 = $1; my $port1 = $2; } else { my $ip1 = $firstIP; my $port1 = " "; } if ($secondIP =~ /([\d.]+)\((\d+)\)/) { my $ip2 = $1; my $port2 = $2; } else { my $ip2 = $secondIP; my $port2 = " "; } push my @XLSarray, ($date, $log, $protocol, $ip1, $port1, $ip2, $port2, $packets); # print information to Excel spreadsheet my $col = 0; foreach my $XLSelement (@XLSarray) { $worksheet->write($row, $col, $XLSelement); $col++; } $row++; } $workbook->close();