open (FP,"/root/logfile");
while(<FP>) {
($host,$rfc931,$user,$date,$request,$URL,$status,$bytes,$refer,$ua) = /^(\S+) (\S+) (\S+) \[([^]]+)\] "(\w+) (\S+).*" (\d+) (\S+) "(\S+)" ".*"/;
}
close(FP);
I can match every other field in the log, but $ua is always empty.
Any ideas?
Which means I usually do it in steps. Normally, I'm not going to use every field, so breaking it down a few at a time isn't a big problem.
(line is the log line)...
($Domain,$rfc931,$authuser,$TimeDate,$Request,$Status,$Bytes,$Referrer,$Agent) = $line =~ /^(\S+) (\S+) (\S+) \[([^\]\[]+)\] \"([^"]*)\" (\S+) (\S+) \"?([^"]*)\"? \"([^"]*)\"/o;