#!/usr/bin/perl # Visitor Information - Process Counts # By Brian Prentice # September 1997 $VisitorFile = "/var/www/html/$ARGV[0]/VisitorInfo/$ARGV[1]"; if (!(-e $VisitorFile)) { exit(1); } open(FILE, "<$VisitorFile"); $firstline = ; if ($firstline !~ "^\n") { close(FILE); exit(1); } print "Content-type: text/html\n\n"; print "\n"; print "Visitor Information\n"; if ($ARGV[2] eq "notable") { print "\n"; print "

Visitor Information

\n"; print "
\n";
	print "No of Visits\tVisitor\n\n";
}
else
{
	print "
\n"; print "

Visitor Information

\n"; print "\n"; print "\n"; } while () { ($dayname, $day, $month, $year, $hour, $minute, $visitor) = split "\t"; chop($visitor); $counts{$visitor}++; } foreach $visitor (sort sortsub keys %counts) { if ($ARGV[2] eq "notable") { printf "%7d\t\t%s\n", $counts{$visitor}, $visitor; } else { print "\n"; } } if ($ARGV[2] eq "notable") { print "\n"; } else { print "
VisitorNo of Visits
$visitor$counts{$visitor}
\n"; } close(FILE); exit(0); sub sortsub { ($counts{$b} <=> $counts{$a}) or ($a cmp $b); }