http://www.perlmonks.org?node_id=552798


in reply to Feedback Appreciated on text-parsing, SQL querying subroutine

The $dbh->prepare is in a loop, with the same statement and handle attributes. You only need to prepare it once:
my $sth2 = $dbh->prepare_cached("select d_id, c_id from d where d_id = ?"); $sth2->execute( $did2 ); # And since you need less clutter on the monitor (my $sth2 = $dbh->prepare_cached(<<"")) -> execute ($did2); select d_id, c_id from d where d_id = ? # line above intentionally left blank