Everything is working fine, but I can't help but stare at the lengths I have to go through when I want to get a single value from the database.
If four statements strikes you as being a great length, then hide the length by wraping it up in a subroutine.
sub the_name {
my $id = shift;
my $sth = $db->prepare("select the_name from table where id = ?"
+);
$sth->execute($id);
my ($the_name) = $sth->fetchrow_array();
$sth->finish();
return $the_name;
}
then, you get the simplicity of
print the_name(3);