my $dbh = DBI->connect('DBI:mysql:foo','foo','foo') or die "Connect Error: $DBI::errstr"; my $count_sth = $dbh->prepare("SELECT COUNT(*) FROM company_info;") or die "Prepare Count Error: $DBI::errstr\n"; $count_sth->execute() or die "Execute Count Error: $DBI::errstr\n"; print $count_sth->fetchrow; $count_sth->finish; $dbh->disconnect;