in reply to Perl Code in HTML
You could save yourself a lot of time and use http://www.google.com/analytics
It's pretty verbose in its statistics and has a lot of cool visitor information features you should check out.