#!/sw/local/bin/perl # the resting place of the log file to search $dir = "/mp/roxen-pages/henric"; # name of the log file $file = "AccessLog"; $total = 0; $count = 0; $users = 0; $home = 0; print " Access statistics of Henric's pages

Access statistics of Henric's pages


"; open(DATA,"$dir/$file") || die "could not open data file $dir/$file!\n"; # march through the log file looking for interesting lines while() { if (/~henric/) { # found the pattern we are interested in @info = split; # some browsers generate a strange syntax if ($info[6] eq "HTTP/1.0\"") { $this = $info[5]; # field 5 is the file accessed that contains # the pattern we are interested in } else { # This is normal $this = $info[6]; # field 6 is the file accessed that contains # the pattern we are interested in } # fix that some browser can't handle the '~' $this = join('~',split('%7E',$this)); # dump any document parameters ($this,$rubbish) = split('\?',$this); $scan = 0; $found = 0; # set found to false # search through the unique values found so far # for the value we are currently looking at while ($scan < $count) { if ($this eq $unique[$scan]) { $found = 1; # set found to true $occurences[$scan] += 1; } $scan++; } if ($found == 0) { # this is a unique entry, add it to our list $unique[$count] = $this; $occurences[$count] = 1; $count++; } $total++; } } if ($users > $home) { $users = $home; } print " There have been $total accesses to my pages (since 30 jan 2000)

"; # do a simple sort so we can display the documents in descending # order with respect to how many times they are accessed for ($i=0; $i<$count-1; $i++) { for ($j=$i+1; $j<$count; $j++) { if ($occurences[$i] < $occurences[$j]) { $tempoccurence = $occurences[$i]; $tempunique = $unique[$i]; $occurences[$i] = $occurences[$j]; $unique[$i] = $unique[$j]; $occurences[$j] = $tempoccurence; $unique[$j] = $tempunique; } } } print "

Accesses ......... Document accessed

\n"; print "
\n"; $count = 0; foreach $this (@unique) { print "
\[$occurences[$count++]\] ....................... $this\n"; } print "
\n"; close(DATA); print "

To see the source for the perl script that generated this page, click here.


Henric Karlsson
";