Update: I fixed a typo. But more importantly, I realized from the latter responses that I was over complicating. Using an unless block to do the error-checking is much easier and more efficient than the eval.
How about:
eval {
$newSeriesSth->execute() || die $newSeriesStr->exrrstr;
};
if ($@) {
if ($@ =~ /duplicate/) {
print "Trying to insert duplicate row.\n";
} else {
die "Unhandled errer. DBI says: $DBI::errstr";
}
}
Or you could try one of the various throw/catch implementations on cpan. (Or wait for Perl6 with built in exception support.)
-pete
"Pain heals. Chicks dig scars. Glory lasts forever."