# This is just an insert statement. What I want to do # is catch any errors, and then vary my actions based # on the error. Can I do this better? $newSeriesSth->execute() || &{ # is this an anonymous sub? if( $newSeriesSth->errstr =~ /duplicate/ ) { # this error is okay, i don't want to quit print "Trying to insert duplicate row.\n"; } else { # some other error, better safe to quit now. die("Unhandled error. DBI says: " . DBI->errstr); } };