or download this
$sqlCount = "SELECT COUNT(*) FROM $user_data_db_name WHERE USER_NA
+ME='$form_values{'USER_NAME'}'";
$sth = $dbh->prepare($sqlCount) || die "Cannot prepare: " . $dbh->
+errstr();
$sth->execute() or die "Cannot execute: " . $sth->errstr();
my $occurences = $sth->fetchrow_arrayref->[0];