my ($count) = $dbh->selectrow_array("SELECT count(*) FROM table WHERE LEFT(colum,3) = 'foo'"); if ($count > 0) { print "Do what you need here"; }