#!/usr/local/bin/perl # bestpics.pl by Sid Sowder # version 1.0 Tue Jun 22 09:22:37 EST 1999 # # Check the keepers file and return a list of the X most appreciated # pictures as a javascript 1.2 array. $MAX = 15; $FILE = "keepers.txt"; open(FILE, $FILE); while () { chomp; chop if (/\\$/); $HITS{$_}++; } close(FILE); foreach $key (sort(keys(%HITS))) { push(@output, sprintf("%03d|$key", $HITS{$key})); } @output = reverse(sort(@output)); foreach $line (@output) { ($hits, $line) = split('\|', $line); $array .= "\"$line\",\n"; last if ($i++ >= $MAX); } chomp($array); # remove training newline? chop($array); # remove training comma $array = "favs = [ ". $array ."]"; print "Content-type: text/html\n\n"; print "$array\n";