My script is attempting to read a log file with common log format. An example of the file is below:
66.249.65.107 - - [08/Oct/2007:04:54:20 -0400] "GET /support.html HTTP
+/1.1" 200 11179
To read the file, I used a while loop and split is using spaces:
#opening log file
open (LOGG, '<', 'IN-access.log');
#reading log file and assigning values
while ($lines = <LOGG>){
($remoteIP,$rfc,$userID,$dateTime,$requestType,$statusCode,$sizeOf
+File) = split ' ', $lines;
print "$statusCode $sizeOfFile\n";
}
However, the split function is actually splitting the spaces inside the data (ie 08/Oct/2007:04:54:20 -0400 <-- this is supposed to be the dateTime variable but because there's a space, its actually two variables according to the script) Any help or reference to help is appreciated.