use constant DS => 'my dsn here'; # later ... my $dbh=DBI->connect(DS); my($color1, $color2, $fontsize); eval { my $sth=$dbh->prepare("SELECT color1, color2, fontsize, ... FROM prefs WHERE user_login=?"); $sth->execute($login); $sth->bind_columns( \( $color1, $color2, $fontsize ) ); $sth->fetch; $sth->finish; # using primary key to only fetch 1 row }; if($@) { print STDERR "Informative error message goes here with $@ for good measure\n"; }