Got it.  Yield goes straight to stdio.  Instead, return the first value 
of that array at the end of the method:
  def count_table
   dbh= DBI.connect(@mydb, @dbuser, @dbpw)
     sth = dbh.execute("SELECT count(*) FROM #@table where 
lead_type_code = #@lead_type_code")
      row = sth.fetch
      #yield row[0]  This will write to STIO immediately
      sth.finish
    dbh.disconnect
    row[0]
  end
end
-- 
Posted via http://www.ruby-forum.com/.