]> git.sesse.net Git - wloh/commitdiff
Factor out get_max_season into a function.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 25 Mar 2012 15:05:11 +0000 (17:05 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 25 Mar 2012 15:05:11 +0000 (17:05 +0200)
www/index.pl

index 33a719f0f43fed5828defb436778e5414df4d282..06babf6e22e66e7944992dbf833c34e15021c573 100755 (executable)
@@ -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;
     <form method="get" action="/">
 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";
      <p>Divisjon: