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; }