good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
Re: unique visitors from html logfileby mbethke (Hermit) |
on Nov 17, 2012 at 07:03 UTC ( [id://1004284]=note: print w/replies, xml ) | Need Help?? |
There are actually only two little things that keep your code from working:
I don't know how big your logs are but another thing you could do is improve that regexp: be as specific as you can about each field. At the very least that means specifying a non-blank character where you need one/ On my machine, parsing a typical log line with your version takes about 5.2µs; if I change $w to /(\S+?)/, it's just about 0.9µs. Adding an /o flag to only have it interpolate and compile the regexp once brings it down to 0.35µs. I'm not sure why the difference is so big as there's not that much backtracking¹ but anyway it helps. I didn't benchmark whether it makes a speed difference but the assignment is much shorter to write as follows:
¹ Using $w = "(.+)" which really backtracks lot takes a whopping 185µs per line.
In Section
Seekers of Perl Wisdom
|
|