On this server (and on most others I administer) I use awstats for statistics. It’s a really nice package that give a pretty decent granularity of the visitors. It’s been working wonderfully for years, and once you get it configured, it is reliable.
Until recently. I installed awstats 7.1, and it worked fine, but suddenly it stopped. Just like that. Adding any key-value configuration option would completely corrupt the output, and all output was gone for searches, bots, etc. It was pretty much useless.
After much wrangling, I decided to face the Perl code. I am not too fond of Perl, finding its way mysterious and inscrutable. I am particularly confounded by variable typing, with the various $ and @, as well as by the automatic variables. Sure, it would be easy enough to get used to it, but why would I? It’s not like I want to write code in Perl (or a lot of other people, for that matter).
But in I went, copying the log files to my local machine and analyzing them. There is a good debug facility in awstats, but it works only from the command line, and it has to be turned on in the configuration file (and then again in the command line output).
Once all was in place, I realized the problem was that all arrays vanished inside the code. Once that was clear, I saw what was going on: a function called UnCompileRegex looked at incoming regular expressions and chopped the “compilation” markers off. Unfortunately, someone changed those and, as a result, UnCompileRegex thought all regular expressions were empty.
The only change seems to have been that the regular expressions are now introduced by a hat “^”. Add that one to the regex parser, and everything works again. In awstats-7.1, that means that line 7,820 changes from:
shift =~ /\(\?[-\w]*:(.*)\)/;
shift =~ /\(\?[-<span style="background-color: #ffff00;">^</span>\w]*:(.*)\)/;
(Notice the extra hat?) That’s it. Now I just have to figure out how to recreate all the logs for the past millennium.