Error Handling - the easy way
my $db_attr = {RaiseError => 1};
eval {
my $dbh = DBI->connect($db_source, $db_user, $db_pswd, $db_attr)
|| die $DBI::errstr;
my $sth = $dbh->prepare($sql);
$sth->execute();
while(my($num, $name) = $sth->fetchrow_array) {
...
}
};
if($@) {
die $@;
}