In the past few months, I have been using the open-source AWStats to get an overview of visitors to this website. AWStats is an excellent program, certainly one of the best of its type, but it has a rather annoying flaw: It only displays versions for the three "major" browsers, i.e. Internet Explorer, FireFox and Netscape.
Now, over half the visits to this website are made in Apple's Safari browser. I would, in fact, argue that Safari is more worthy of being classified as a "major" browser than the ailing AOL-promotion that is Netscape Navigator. As a consequence, I am more interested in the version breakdown for Safari than the other browsers.
A less nerdishly inclined man might have thrown his hands in the air, exclaimed "Such is life!" with a sigh and thought no more of it. However, I spent a couple of hours hacking away at the AWStats Perl code...and...lo and behold!

Yes, AWStats can now display a version breakdown for the Safari browser. I have submitted my changes to the project maintainer and hope to get them into the next official release.
This was not as simple to implement as might be expected, since the Safari User Agent string does not contain the browser version, as such, but only the build number. A FireFox User Agent string looks something like this:
It is plainly quite easy to use a regular expression to get the version (1.0.7). A Safari User Agent string, on the other hand, looks like this:
The only relevant number we get in the string is "412", which tells us that it is the 412th official build of Safari. This tells us nothing about the official versioning. For that, I needed to construct a hash to map build numbers to version releases:
%BrowsersSafariBuildToVersionHash =
(
'85.5' => '1.0',
'85.7' => '1.0.2',
'85.8' => '1.0.3',
'85.8.1' => '1.0.3',
'100' => '1.1',
'100.1' => '1.1.1',
'125.7' => '1.2.2',
'125.8' => '1.2.2',
'125.9' => '1.2.3',
'125.11' => '1.2.4',
'125.12' => '1.2.4',
'312' => '1.3',
'312.3' => '1.3.1',
'312.3.1' => '1.3.1',
'412' => '2.0',
'412.2' => '2.0',
'412.2.2' => '2.0',
'412.5' => '2.0.1',
'416.12' => '2.0.2'
);Thus, by regexping after the build number and mapping it via
%BrowsersSafariBuildToVersionHash, I can get a breakdown of versions.
Yes, it's good to be a nerd ;)
(Sveinbjörn)

0
▽
vá, ég las þetta í alvörunni! Trúi því varla! En þér til mikillar gleði þá mun IE gestir á síðunni minnka þar sem ég gerði gegn tilmælum yfirmanna minna (síðasta mail sem fékk frá þeim var okkur bannað að setja inn forrit) og installaði firefox á 2 vélar. Þeim mun fara fjölgandi!