http://www.byte.com/art/download/browsers.pl (PC Press Internet CD, 03/1996)
# BROWSERS - Analyze link-tracking log by browser and OS
#
# Expects ADVDIR to contain one or more custom log files written by LOGLINK.
#
# Jon Udell, BYTE, jon_u@dev5.byte.com,judell@bix.com
require '/cgi-bin/cgi-lib.pl';
print &cgi_PrintHeader;
print "Browser stats since 10/10/95";
print "";
print &cgi_StdHdr(1);
print "Browser stats since 10/10/95
";
opendir(ADVDIR,"/log/") || print "Cannot open stats dir.";
@advs = grep (!/^\.|^\.\./,sort readdir(ADVDIR));
foreach $adv (@advs)
{
open (HITS, "d:/jon/adv/$adv") || die "Cannot open stats file.";
while ()
{
chop;
if (/Mozilla/ && !/MSIE/) # watch out for "cloaked" MSIE!
{$Mozilla++;}
if (/Mosaic/)
{$Mosaic++;}
if (/Microsoft/ || /MSIE/)
{$Microsoft++;}
if (/Lynx/)
{$Lynx++;}
if (/WebExplorer/)
{$WebExplorer++;}
if (/NetCruiser/)
{$NetCruiser++;}
if (/Windows|Microsoft|Win32|Quarterdeck|Chameleon|AIR_Mosaic|SPRY_Mosaic|Win16|WinNT|WindowsNT|Win95/)
{$Windows++;}
if (/Macintosh/)
{$Macintosh++;}
if (/X11|X Window/)
{$UnixGUI++;}
if (/Lynx/)
{$UnixText++;}
if (/WebExplorer/)
{$OS2++;}
($date, $dow, $time, $ip, $browser) = split(/ ~ /);
$BrowserList{$browser}++;
$links++;
}
}
$hits = 0;
foreach $browser (sort keys %BrowserList)
{
$hits += $BrowserList{$browser};
push (@items,sprintf("%-40.40s%5.5s\n",$browser,$BrowserList{$browser}));
}
print "";
print "Browser summary";
print "Browser | Hits | % |
";
print sprintf ("Netscape | %d | %.2f |
", $Mozilla, $Mozilla/$hits);
print sprintf ("Mosaic | %d | %.2f |
", $Mosaic, $Mosaic/$hits);
print sprintf ("Microsoft | %d | %.2f |
", $Microsoft, $Microsoft/$hits);
print sprintf ("Lynx | %d | %.2f |
", $Lynx, $Lynx/$hits);
print sprintf ("WebExplorer | %d | %.2f |
", $WebExplorer, $WebExplorer/$hits);
print sprintf ("NetCruiser | %d | %.2f |
", $NetCruiser, $NetCruiser/$hits);
print sprintf ("Accounted for | %d | %.2f |
", $Mozilla+$Mosaic+$Microsoft+$Lynx+$WebExplorer+$NetCruiser, ($Mozilla+$Mosaic+$Microsoft+$Lynx+$WebExplorer+$NetCruiser)/$hits);
print "
";
print "";
print "Platform summary";
print "Platform | Hits | % |
";
print sprintf ("Windows | %d | %.2f |
", $Windows, $Windows/$hits);
print sprintf ("UnixGUI | %d | %.2f |
", $UnixGUI, $UnixGUI/$hits);
print sprintf ("UnixText | %d | %.2f |
", $UnixText, $UnixText/$hits);
print sprintf ("Macintosh | %d | %.2f |
", $Macintosh, $Macintosh/$hits);
print sprintf ("OS/2 | %d | %.2f |
", $OS2, $OS2/$hits);
print sprintf ("Accounted for | %d | %.2f |
", $Windows+$Macintosh+$UnixGUI+$UnixText+$OS2, ($Windows+$Macintosh+$UnixGUI+$UnixText+$OS2)/$hits);
print "
";
print "";
foreach $item (@items)
{print $item;}
print "
";
print "";