From: Steinar H. Gunderson Date: Sun, 25 Mar 2012 15:05:11 +0000 (+0200) Subject: Factor out get_max_season into a function. X-Git-Url: https://git.sesse.net/?p=wloh;a=commitdiff_plain;h=07a946e7bcebf9c7c0e2e94d0c923c87a740f474 Factor out get_max_season into a function. --- diff --git a/www/index.pl b/www/index.pl index 33a719f..06babf6 100755 --- a/www/index.pl +++ b/www/index.pl @@ -41,6 +41,12 @@ sub color { return int(255.0 * ($x ** (1.80))); } +sub get_max_season { + my $dbh = shift; + my $ref = $dbh->selectrow_hashref('SELECT MAX(sesong) AS max_sesong FROM fotballserier'); + return $ref->{'max_sesong'}; +} + sub make_table { my ($lowest_division, $used_ratings, $used_cov) = @_; @@ -184,12 +190,7 @@ printf <<"EOF", $match_stddev;
EOF -$q = $dbh->prepare('SELECT MAX(sesong) AS max_sesong FROM fotballserier'); -$q->execute; -my $season; -while (my $ref = $q->fetchrow_hashref) { - $season = $ref->{'max_sesong'}; -} +my $season = get_max_season($dbh); print <<"EOF";

Divisjon: