http://www.perlmonks.org?node_id=1003290


in reply to [SOLVED] Splitting a file using "common log format" help

Using Text::ParseWords.
use strict; use warnings; use Text::ParseWords; while (<DATA>) { if (s/(\[.*?\])//) { my $dateTime = $1; my ($remoteIP,$rfc,$userID,$requestType,$statusCode,$sizeOfFil +e) = quotewords(qr/\s+/, 0, $_); print "<$remoteIP> <$rfc> <$userID> <$requestType> <$statusCod +e> <$sizeOfFile>\n"; } } __DATA__ 66.249.65.107 - - [08/Oct/2007:04:54:20 -0400] "GET /support.html HTTP +/1.1" 200 11179