my $rc=$sth->execute... my $tmpl=HTML::Template->new... if ($rc==1) { my ($count)=$sth->fetchrow_array; # I only use this when fetching a single value # otherwise I use fetchrow_hashref $tmpl->param(replycount=>$count); } ... # lots more code, presumably print $tmpl->output;