#!/usr/bin/perl ## Modify below to the absolute path of your input file: open(INPUT, "/hsphere/local/home/ssscc/ssscc.org/registered.bout") or Error("Can't open input: $!"); ## Here we pull in the data and build a simple structure, we'll sort ## it later during output: while() { @line = split(/\|/); my ($class, $scca, $first, $last, $make, $model, $year, $number); $class = (defined($line[1]) ? "\U$line[1]" : ""); # force uppercase $scca = (defined($line[5]) ? "\U$line[5]" : ""); # force uppercase $first = (defined($line[6]) ? $line[6] : ""); $last = (defined($line[7]) ? $line[7] : ""); $make = (defined($line[2]) ? $line[2] : ""); $model = (defined($line[3]) ? $line[3] : ""); $year = (defined($line[4]) ? $line[4] : ""); $number = (defined($line[0]) ? $line[0] : ""); $entries{"$class"}{"$number"} = "$class$scca$first $last$number$year $make $model\n"; # make it easy to get a unique sorted list of classes: $classes{"$class"} = "$class"; } close(INPUT); ##Print out the starting html stuff: print "Content-type: text/html\n\n"; print "Entry list\n\n"; print "\n"; ## Now, we'll sort them and spit them out: print "\n"; foreach $class (sort(keys(%classes))) { print "\n"; $entryref = $entries{"$class"}; foreach $key (sort(keys(%{$entryref}))) { # entries are sorted by car number print $$entryref{$key}; } } print "
SSSCC ClassSCCA ClassNameNumberCar
$class
\n\n"; print "\n"; exit(0); # That's it! sub Error { my (@msg) = shift; print "Content-type: text/html\n\n"; print "Error!\n\n"; print "Uh oh, something went wrong. The following might be a clue:

\n"; print join("
", @msg); print "

\n"; print "PATH: $ENV{'PATH'}
\n"; print "PWD: " . `pwd`; print ""; die(@msg); }