$sth5 = $dbh->prepare("SELECT round,department,score FROM trees WHERE sport = \'$sport\' AND year = \'$year\' ORDER BY round DESC")|| die "couldn't prepareSQL statement"; $sth5->execute || die "can't execute sql statement"; $rowcount = 0; while (@row = $sth5->fetchrow_array()) { $round = $row[0]; $teamname = $row[1]; $Score = $row[2]; push @list_of_teamdata, qw("$round $teamname $score"); $rowcount++; } #### my $statement = q{ SELECT round , department , score FROM trees WHERE sport = ? AND year = ? ORDER BY round DESC }; my $list_of_teamdata = $dbh->selectall_arrayref( $statement, {}, $sport, $year, );