in reply to Perl Code Efficiency Issue

The thing that hits me is the two connects to $dbh.
my $dbh = DBI->connect("DBI:ODBC:$db",$user, $pass, {RaiseError => 1}) +; my $dbh = DBI->connect("DBI:ODBC:$ibm",$user, $pass) || print "Connect + fail: $!";
You are executing a SELECT after the first one, but not getting the results. The $sth->finish is commented out, but that may give you a memory leek. You should probably disconnect the dbh before opening it again. I can't say that this will cause a "hang", but it doesn't look right.