#!/usr/local/bin/perl -W use CGI qw(standard); use CGI::Carp qw(fatalsToBrowser); use DBI; use Getopt::Std; use CGI::Request; ##initialise oracle connection $ENV{‘ORACLE HOME’)= ‘/oracle/uo1’; $host = “neptune”; $sid = “ora1”; $user = “tayloja1”; $password = “the.best”; $sport = ‘basketball’; my $cgi = new CGI::Request; my $year =$cgi->param("year"); my %teams; $teams{"team$_"} = param("team$_") for 1..11; foreach $team (keys %teams) { If ($team ne ‘please specify’){ Push @list1,$team1; } } ##Once the list is created I need to randomise the array. $firstrandom = $list1 [rand @list1]; Push @list2, $random; $count = $#list1 while ($count != 0){ ###create list2 $random = $list1 [ rand @list1]; $present = “false”; For $I (0..$#list2){##check to see if team is already in list If ($random == $list2[$I]) { $Present == ‘true’; }; If ($Present == ‘false’) { ##if not add it to @list2 Push @list2, $random; $count--; }; }; Database creation ## connect to oracle database. my $dbh = DBI->connect( "dbi:Oracle:host=$host;sid=$sid",$username, $password) || die "Can't connect to Oracle"; For $I (0..$#list2) { $teampos = $I + 1; my$sth = $dbh->do("INSERT INTO results VALUES('$year',‘$sport’,‘$list2[$I],‘0’)") || die "Can't execute SQL insert results statement"; my$sth2 = $dbh->do("INSERT INTO trees VALUES('$year',‘$sport’, ‘$teampos’,‘$list2[$I]’,‘0’)") || die "Can't execute SQL insert trees statement"; For $I (1..$#list2){ $teampos = $I + $#list2+1; my$sth3 = $dbh->do("INSERT INTO trees VALUES('$year',‘$sport’, ‘$teampos’,‘TBA’,‘0’)") || die "Can't execute SQL insert trees statement"; } my $compsize = $#list2+1; my $sth4 = $dbh->do("INSERT INTO compsize VALUES('$year',‘$sport’, ‘$compsize’)") || die "Can't execute SQL insert results statement"; my $sth5 = $dbh->prepare("SELECT round, teamname, score from trees where sport = ‘$sport’ and year = ‘$year’, ORDER BY round DESC") || die "Can't prepare SQL get data statement"; $sth5->execute || die “can’t execute sql statement”; ##need to get all the data one row at a time from the table. my @row; $rowcount = 0; while (@row = $sth5->fetchrow_array()) { $round = $row[0]; $teamname = $row[1]; ## need to put each row into the list. $Score = $row[2]; of lists a variable at a time push (@{list_of_teamdata[$rowcount]}, qw($round $teamname $score); $rowcount++; } my $compsize = $#list2+1; If ($compSize = 7); Print “Content-Type: text/html\n\n”; Print “\n”; Print “\n”; Print “ tree7\n”; Print “\n”; Print “\n”; Print “\n”; Print “\n”; Print “\n”; Print “\n”; Print “\n”; Print “\n”; Print “\n”; Print “\n” Print “
   

\n”; Print “

\n”; Print “

\n”;