The last time I considered using eval is years ago. I remember that I had read an article somewhere that doing eval could lead to dramatic performance issues.
I want to use eval{} to check my db-transactions. I looking for informations at perldoc eval, but there is nothing mentioned about performance influences. (I also looked at programming the perl dbi book, eval is only mentioned one time.... and the http://www.perl.com/pub/a/1999/10/DBI.html and http://www.saturn5.com/~jwb/dbi-examples.html) In general I am a little bit unsure about DBI and EVAL, both things I rarely needed or used before. ################################### use DBI; use DBD::mysql; eval { my $dbh = DBI->connect("DBI:mysql:dummy_db:test_db:3333",'adm','adm'); }; if ($@) { ... handle errror... } my $sth = $db->prepare("select dummies from dummy_table"); eval{ $sth->execute(); }; if ( $@ ) { #... handle errors print __LINE__ . " sth->err " . $sth->err() . "\n"; print __LINE__ . " sth->errstr " . $sth->errstr() . "\n"; print __LINE__ . " sth->state " . $sth->state() . "\n"; print __LINE__ . " DBI::err " . $DBI::err . "\n"; print __LINE__ . " DBI::errstr " . $DBI::errstr . "\n"; print __LINE__ . " DBI::state " . $DBI::state . "\n"; } #versus my $dbh2 = DBI->connect("DBI:mysql:dummy_db:test_db:3333",'adm','adm'); if (defined $DBI::errstr) { #...error handling... } my $sth2 = $db->prepare("select dummies from dummy_table"); $sth2->execute(); if (defined $DBI::errstr) { #..error handling... } ##############################################################