#!/usr/bin/perl use CGI qw(:standard); my ($name) = param("name"); my ($userchoice) = param("userchoice"); if ($name eq "userchoice") { $name = $userchoice; } print "Content-type: text/html\n\n"; $holdMe = makeHTML($name); if ($holdMe) { print($holdMe); } else { print "Search Error

There was an error.

"; } ############################################################ sub makeHTML { my ($newname) = @_; open (TEMP, "namefile.txt") || return ("1"); while () { if (m/1/gi) { $nameList1 = "namelist1.txt"; $nameList2 = "namelist2.txt"; } else { $nameList1 = "namelist2.txt"; $nameList2 = "namelist1.txt"; } } close (TEMP); open (TEMP, ">namefile.txt") || return ("1"); print (TEMP "$nameList2"); close (TEMP); open (LISTIN, "$nameList1") || return ("2"); open (LISTOUT, ">$nameList2") || return ("3"); $stringOut = "Bak Boy #4 Baby Name Survey"; $stringOut .= "

Bak Boy #4 Baby Name Survey

"; $stringOut .= "
(We think it's a boy without a winkle)
"; $stringOut .= "
"; $found = 0; while() { $line = $_; ($name, $votes) = split/\t/, $line, 2; chomp($votes); if ($newname eq $name) { $votes++; $found++; } $stringOut .= "$name ($votes)
"; print (LISTOUT "$name\t$votes\n"); } if (!$found && $newname) { $name = $newname; $votes = 1; $stringOut .= "$name ($votes)
"; print (LISTOUT "$name\t$votes\n"); } close (LISTIN); close (LISTOUT); $stringOut .= "
"; $stringOut .= ""; $stringOut .= ""; $stringOut .= ""; return ($stringOut); }