my $teamposition; my $thisteam; my $thisscore; for $_ ( 1..13){ $thisteam = $teams{"team$_"}; $thisscore = $scores{"score$_"}; $teamposition = $_; my $sth1 = $dbh->do("UPDATE trees SET department = \'$thisteam\' WHERE sport = \'$sport\' AND round = \'$teamposition\'")|| die "Can't execute SQl update 1"; my $sth2 = $dbh->do("UPDATE trees SET score = \'$thisscore\' WHERE sport = \'$sport\' AND round = \'$teamposition\'")|| die "Can't execute SQl update 2"; my $sth3 = $dbh->do("UPDATE results SET score =\'$thisscore\' WHERE year = \'$thisyear\' AND sport =\'$sport\' AND department = \'$thisteam\'")|| die "Can't execute SQl update 3"; }